Consider the following DataFrame
.
n v1 v2 v3 v4 v5
0 1 2 3 4 5
1 1 2 3 4 5
2 1 2 3 4 5
For each row, I want to add the values of v2
, v3
, v4
to a list and multiply the values in the list with v5
and put the result into a new column v6
such that I end up with a DataFrame
like this:
n v1 v6
0 1 [10, 15, 20]
1 1 [10, 15, 20]
2 1 [10, 15, 20]
How can I achieve this in Pandas?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…