0

I have two Pandas DataFrame of unequal shape and I want to generate a resultant DataFrame containing the product of both. DataFrame 1:

X_D X_M X_Dt X_G
1   0   0    0
0   1   0    0
0   0   1    0
0   0   0    1

DataFrame 2:

S_D S_M S_Dt S_G
0   1   0    0
0   2   0    0
0   3   0    0
0   4   0    0
0   5   0    0
0   6   0    0

Resultant DataFrame:

X_D X_M X_Dt X_G S_D S_M S_Dt S_G
1   0   0    0   0   1   0    0
1   0   0    0   0   2   0    0
1   0   0    0   0   3   0    0
1   0   0    0   0   4   0    0
1   0   0    0   0   5   0    0
1   0   0    0   0   6   0    0
0   1   0    0   0   1   0    0
0   1   0    0   0   2   0    0
0   1   0    0   0   3   0    0
0   1   0    0   0   4   0    0
0   1   0    0   0   5   0    0
0   1   0    0   0   6   0    0
.
.
.
0   0   0   1   0   6    0    0

I was able to do it using brute force method but it is computationally very inefficient for a large number of sample. I want to know if there's a Pythonic way of doing it.

Kshitiz
  • 3,431
  • 4
  • 14
  • 22

0 Answers0