Pandas, merging two dataframes on multiple columns, and multiplying result

You could merge and them multiply:

merged = df1.merge(df2, on=['Name', 'Event'])
merged['ResultFactor'] = merged.Factor1 * merged.Factor2
result = merged.drop(['Factor1', 'Factor2'], axis=1)

print(result)

Output

   Name Event  ResultFactor
0  John     A           2.4
1  John     B           1.5
2   Ken     A           3.0

Leave a Comment