title: Generate all multiplicative (product) combinations of columns in a pandas dataframe
body: <p>I would like to generate all 2-way (and possibly 3-way) &quot;multiplicative&quot; combinations (i.e., column1 x column2, column2 x column3, column1 x column3, column1 x column 2 x column3, etc) of a pandas dataframe with about 100 columns (and 500K rows). I plan to evaluate these combinations for identifying high performing 'feature interactions' in a predictive model.</p>
  <p>Thus far, my attempts (at either repurposing existing stackoverflow suggestions or other online materials) to generate the combinations have not been successful. Here is my minimal example with a very simple dataframe and the code I am using:</p>
  <pre><code>df = pd.DataFrame({'age':[10,20], 'height':[5, 6], 'weight':[100,150]})
  
  sample_list = df.columns.to_list()
  output = list(combinations(sample_list, 2))
  
  pd.DataFrame(df[x].prod(axis = 1) for x in output)
  </code></pre>
  <p>My above code yields a &quot;key error: ('age', 'height').  The final output should contain all 2-way (and potentially 3-way) 'multiplicative' combinations only (i.e., not include the original columns).
  <a href="https://i.stack.imgur.com/ApByY.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ApByY.png" alt="enter image description here" /></a></p>
  <p>Can somebody please guide me to the solution? Also, how would one modify the code to generate all 3-way combinations? Any suggestions to optimize for limited RAM (~30GB) are also appreciated.</p>