I have data in pandas dataframe with 1 minute time step. This data is not recorded continuously, now I would like to split all my data into separate event based on the condition below : If there is continuous data recorded for 5min or more then only it is considered as a event and for such event data need to extracted separately. Is there a way to implement this in pandas dataframe.
My data look likes this (with the Event column as result):
Date X Event
2017-06-06 01:08:00 0.019 1
2017-06-06 01:09:00 0.005 1
2017-06-06 01:10:00 0.03 1
2017-06-06 01:11:00 0.005 1
2017-06-06 01:12:00 0.003 1
2017-06-06 01:13:00 0.001 1
2017-06-06 01:14:00 0.039 1
2017-06-06 01:15:00 0.003 1
2017-06-06 01:17:00 0.001 nan
2017-06-06 01:25:00 0.006 nan
2017-06-06 01:26:00 0.006 nan
2017-06-06 01:27:00 0.032 nan
2017-06-06 01:29:00 0.013 2
2017-06-06 01:30:00 0.065 2
2017-06-06 01:31:00 0.013 2
2017-06-06 01:32:00 0.001 2
2017-06-06 01:33:00 0.02 2
2017-06-06 01:38:00 0.05 nan
2017-06-06 01:40:00 0.025 3
2017-06-06 01:41:00 0.01 3
2017-06-06 01:42:00 0.008 3
2017-06-06 01:43:00 0.009 3
2017-06-06 01:44:00 0.038 3
2017-06-06 01:45:00 0.038 3
Your suggestion is highly appreciated.
Using the solution provided by nnnmmm, result looks like this
2015-01-01 03:24:00 NaN
2015-01-01 04:59:00 NaN
2015-01-01 05:01:00 NaN
2015-01-01 05:02:00 NaN
2015-01-01 05:03:00 NaN
2015-01-13 01:12:00 1.0
2015-01-13 01:13:00 1.0
2015-01-13 01:14:00 1.0
2015-01-13 01:15:00 1.0
2015-01-13 01:16:00 1.0
2015-01-13 01:49:00 1.0
2015-01-13 01:50:00 1.0
2015-01-13 01:51:00 1.0
2015-01-13 01:52:00 1.0
2015-01-13 01:53:00 1.0
2015-01-13 01:54:00 1.0
2015-01-13 01:55:00 1.0
In this case, there is time change between 01:16:00 and 01:49:00, it shouldn't consider it as a same event rather 01:49:00 should be the second event.