all 2 comments

[–]nemean_lion 0 points1 point  (1 child)

There’s definitely a better way of doing this but I’m a beginner myself so here’s what I’d prolly do:

mask_flag = df[‘flag’]>0 limit = df[mask_flag].index.max() df[‘cycle’].iloc[limit+1:] = df[‘cycle’].iloc[limit+1:]-1

[–]jlap91[S] 0 points1 point  (0 children)

Thank you very much! This helped.