I am wondering whether it is possible via a Pandas function to achieve the following. Given two Pandas DataFrames, get a new DataFrame whose columns are the Cartesian product of the columns in the two given DataFrames. That is, in a simple example, if we have the two DataFrames:
df1 = pd.DataFrame([[1,2], [1,2]], columns = ['a', 'b'])
df2 = pd.DataFrame([[3,4], [3,4]], columns = ['c', 'd'])
which look like
df1                 df2
   a  b                c  d
0  1  2             0  3  4
1  1  2             1  3  4
I am looking for a function that provides , without looping, the following:
df
   a_c  a_d  b_c  b_d
0  3    4    6    8
1  3    4    6    8
 
     
     
     
    