Home > Software design >  How to perform multiplication of a column value row wise with another dataframe?
How to perform multiplication of a column value row wise with another dataframe?

Time:04-17

I have a dataframe like this enter image description here. And I have to multiply the 'Factor' column value row wise with another dataframe enter image description here


I want result like this

enter image description here

I have tried with df.mul. But it is giving me all NAN values. How to get this resultant matrix using python

CodePudding user response:

pd.DataFrame(df2.to_numpy() * df1.to_numpy())

CodePudding user response:

df2.apply(lambda x: x * df1['factor'])
  • Related