pandas outer product of two dataframes with same index
问题 Consider the following dataframes d1 and d1 d1 = pd.DataFrame([ [1, 2, 3], [2, 3, 4], [3, 4, 5], [1, 2, 3], [2, 3, 4], [3, 4, 5] ], columns=list('ABC')) d2 = pd.get_dummies(list('XYZZXY')) d1 A B C 0 1 2 3 1 2 3 4 2 3 4 5 3 1 2 3 4 2 3 4 5 3 4 5 d2 X Y Z 0 1 0 0 1 0 1 0 2 0 0 1 3 0 0 1 4 1 0 0 5 0 1 0 I need to get a new dataframe with a multi-index columns object that has the product of every combination of columns from d1 and d2 So far I've done this... from itertools import product pd