cross-join

cartesian product in pandas

cartesian product in pandas Question: I have two pandas dataframes: from pandas import DataFrame df1 = DataFrame({‘col1′:[1,2],’col2’:[3,4]}) df2 = DataFrame({‘col3’:[5,6]}) What is the best practice to get their cartesian product (of course without writing it explicitly like me)? #df1, df2 cartesian product df_cartesian = DataFrame({‘col1′:[1,2,1,2],’col2′:[3,4,3,4],’col3’:[5,5,6,6]}) Asked By: Idok || Source Answers: In recent versions of …

Total answers: 13