I have a dataframe:
df =
col1 | Aciton1 |
---|---|
1 | A |
2 | B |
3 | C |
1 | C |
I want to edit df, such that when the value of col1 is bigger than 1 , take the value from Action1.
So I will get:
col1 | Aciton1 | Previous_Aciton |
---|---|---|
1 | A | Initial Action |
2 | B | A |
3 | C | B |
1 | C | Initial Action |
CodePudding user response:
If there are no negative and 0
values and each group starting by 1
is possible use
the result: