0

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

2 Answers 2

3
pd.DataFrame(df2.to_numpy() * df1.to_numpy())
Sign up to request clarification or add additional context in comments.

3 Comments

I think it is much more faster than apply
Yes,this is the better way. I'd be curious why he is getting nan values with my solution, i tested it and it worked
@Rabinzel and I test your sol for benchmark and it was ok
1
df2.apply(lambda x: x * df1['factor'])

1 Comment

Getting NAN values.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.