Reputation: 81
I want to add a new column which is a weighted average of the 2. and 3. columns.
I heard that df.iloc is the way to go, but I am not sure how to apply it on this problem.
Upvotes: 1
Views: 60
Reputation: 862481
Python counts from 0
, so for select second cand third column use 1,2
in DataFrame.iloc
:
df.iloc[:, 1] * 0.6 + df.iloc[:, 2] * 0.4
Upvotes: 1