cartesian product in pandas
In recent versions of Pandas (>= 1.2) this is built into merge so you can do: from pandas import DataFrame df1 = DataFrame({‘col1′:[1,2],’col2’:[3,4]}) df2 = DataFrame({‘col3′:[5,6]}) df1.merge(df2, how=’cross’) This is equivalent to the previous pandas < 1.2 answer but is easier to read. For pandas < 1.2: If you have a key that is repeated … Read more