I have a pandas DataFrame
df = pd.DataFrame({"A": [10,20,30], "B": [20, 30, 10], "C": [20, 30, 10]})
df
A B C
0 10 20 20
1 20 30 30
2 30 10 10
and another ndarray w = array([0.2, 0.3, 0.4])
how do I add column D such that its value is dot product of each row and w
i.e. the value for D[0] will be np.dot(df.iloc[0],w) = 16
likewise, value for D[1] is 25 (np.dot(df.iloc[1],w) = 25.
(I am thinking apply() function but not sure how to use it, using for loop might be inefficient)
thanks,