Here is a sample data. Whenever I see a Not win
or Not fail
in Event
column, I want to change the value in row-1 of Time
column to 0.
x = pd.DataFrame({'Id': [102,303,944, 111, 675, 236], 'Event':['win', 'fail','Not fail','win','win','Not win'],
'Time':[10,22,0, 23, 45, 0]})
This is how the outcome should look.
Event Id Time
0 win 102 10
1 fail 303 0
2 Not fail 944 0
3 win 111 23
4 win 675 0
5 Not win 236 0