I have a DataFrame with columns A
and B
. Now I want to produce column C
like this:
A B C
index
1 0 50 NaN
2 1 60 60
3 0 40 60
4 0 30 60
5 1 40 40
C
gets the value of B
if A==1
in this row. Then this value is kept in coming rows until next time A==1
.How can I do this in vectorized fashion?
Aucun commentaire:
Enregistrer un commentaire