title: Get combinations of multiple columns (Cartesian product) of a pandas dataframe?
body: <p>So I have a dataframe representing various model estimates for the likelihood of each of a group of candidates winning an election.</p>
  
  <pre><code>             Steve     John      
      Model1   0.327586  0.289474 
      Model2   0.322581  0.285714 
      Model3   0.303030  0.294118
  </code></pre>
  
  <p><strong>I want a dataframe representing all of the combinations of model values across columns, i.e. Cartesian product of all columns</strong>. So the above would be transformed to the below.</p>
  
  <pre><code>             model Steve     value Steve    model John     value John     
      0        Model1          0.327586       Model1         0.289474
      1        Model1          0.327586       Model2         0.285714
      2        Model1          0.327586       Model3         0.294118
      3        Model2          0.322581       Model1         0.289474
      4        Model2          0.322581       Model2         0.285714
      5        Model2          0.322581       Model3         0.294118
      6        Model3          0.303030       Model1         0.289474
      7        Model3          0.303030       Model2         0.285714
      8        Model3          0.303030       Model3         0.294118
  </code></pre>
  
  <p>The above is the simple case, but in theory I would like to be able to do this for N models and M candidates, resulting in a dataframe with N^M rows and 2M columns (in practice N &lt; 20, M &lt; 6).</p>
  
  <p>In searching for an answer I've seen a lot of recommendations for the <code>itertools</code> module for stuff like this, but couldn't figure out how to get all of the combinations across multiple lists (<code>itertools.combinations</code> seems to only work for finding all of the combinations within a single list).</p>