I have two different dataframes of different length but have two columns in common.
I need to perform a math operation let say multiply the float value in VALUE column of 1st dataframe with value in NUMBER column in 2nd dataframe if the condition matches with same ID and Class.
Eg:
In 1st dataframe if ID is 103 and Class is A, then the value 2.301308 must be multiplied with the value 0.15 in 2nd dataframe whose ID is 103 and Class is A. Likewise for each ID and Class of two dataframes matches the value in VALUE column should be multiplied with value in NUMBER column.
I tried by df.assign function
df1.assign(VALUE = df1['VALUE']*(df2.NUMBER.loc[(df2.ID == df1.ID) & (df2.Class == df1.Class)]))
Got the error
ValueError: Can only compare identically-labeled Series objects
What went wrong or any other solution for this?
Thanks in advance!