Pandas once condition is met in column delete n rows

  pandas, python

I have a DataFrame that looks like df = pd.DataFrame({'col1': [.8,.9,1,1,1,.9,1,.9,.8,.7,.6,.5,.4,.3]}).

The goal I have is once a number 1 in ‘col1’ is found, remove the next five rows.

Example

    col1
0   0.8
1   0.9
2   1.0
3   1.0
4   1.0
5   0.9
6   1.0
7   0.9
8   0.8

Expected Output

    col1
0   0.8
1   0.9
2   1.0
3   0.8

Any ideas?

Source: Python Questions

LEAVE A COMMENT