Working on Pandas and need to remove the n consecutive rows in the DataFrame based on value in column.
In the example bellow, there is an event at 17:00:01 that last for 2 sec. I need the following 2 rows in that times span dropped. There is another event at 17:00:04 and then row 17:00:05 should be dropped.
Unsure on how to approach this. Use masking in a lamda?
t = pd.to_timedelta(df['EventSeconds'], unit='s')
mask = df['2019-01-07 17:00:02' : '2019-01-07 17:00:02' + t]
I have:
Index EventSeconds OtherColumn
07/01/2019 16:59:59 0 2
07/01/2019 17:00:00 2 3
07/01/2019 17:00:01 0 4
07/01/2019 17:00:02 0 5
07/01/2019 17:00:03 0 6
07/01/2019 17:00:04 1 7
07/01/2019 17:00:05 0 8
07/01/2019 17:00:06 0 9
I need:
Index EventSeconds OtherColumn
07/01/2019 16:59:59 0 2
07/01/2019 17:00:00 2 3
07/01/2019 17:00:03 0 6
07/01/2019 17:00:04 1 7
07/01/2019 17:00:06 0 9