I tried to get the weighted average of each product for each person. So for Tom, it should have 20x1.0+19x2.0+10x3.0, I also hope to have the weights*product by each product as well.
data = {'Name':['Tom', 'nick', 'krish', 'jack'], '1stproducts':[20, 21, 19, 18], '2ndproduct': [19, 28, 10, 10],
'3rdproduct': [10, 18, 20, 30]}
df = pd.DataFrame(data)
weights = {"weights": [1.0, 2.0, 3.0]}
df2 = pd.DataFrame(weights)
I have tried pd.DataFrame.multiply(df, df2, axis = 1)
, but I got NaN for all values.