I'm migrating some code from python list primitive to a pandas implementation. For some time series, I want to find all the discontinuous segments with their durations. Is there a clean way of doing this in pandas?
My dataframe looks like this:
In [23]: df
Out[23]:
2016-07-01 05:35:00 60.466667
2016-07-01 05:40:00 NaN
2016-07-01 05:45:00 NaN
2016-07-01 05:50:00 NaN
2016-07-01 05:55:00 NaN
2016-07-01 06:00:00 NaN
2016-07-01 06:05:00 NaN
2016-07-01 06:10:00 NaN
2016-07-01 06:15:00 NaN
2016-07-01 06:20:00 NaN
2016-07-01 06:25:00 NaN
2016-07-01 06:30:00 NaN
2016-07-01 06:35:00 NaN
2016-07-01 06:40:00 NaN
2016-07-01 06:45:00 NaN
2016-07-01 06:50:00 NaN
2016-07-01 06:55:00 NaN
2016-07-01 07:00:00 NaN
2016-07-01 07:05:00 NaN
2016-07-01 07:10:00 NaN
2016-07-01 07:15:00 NaN
2016-07-01 07:20:00 NaN
2016-07-01 07:25:00 NaN
2016-07-01 07:30:00 NaN
2016-07-01 07:35:00 NaN
2016-07-01 07:40:00 NaN
2016-07-01 07:45:00 63.500000
2016-07-01 07:50:00 67.293333
2016-07-01 07:55:00 67.633333
2016-07-01 08:00:00 68.306667
...
2016-07-01 11:20:00 NaN
2016-07-01 11:25:00 NaN
2016-07-01 11:30:00 62.000000
2016-07-01 11:35:00 69.513333
2016-07-01 11:40:00 64.931298
2016-07-01 11:45:00 51.980000
2016-07-01 11:50:00 55.253333
2016-07-01 11:55:00 51.273333
2016-07-01 12:00:00 52.080000
2016-07-01 12:05:00 54.580000
2016-07-01 12:10:00 55.306667
2016-07-01 12:15:00 55.200000
2016-07-01 12:20:00 57.140000
2016-07-01 12:25:00 57.020000
2016-07-01 12:30:00 57.526667
2016-07-01 12:35:00 57.880000
2016-07-01 12:40:00 67.286667
2016-07-01 12:45:00 58.153333
2016-07-01 12:50:00 57.460000
2016-07-01 12:55:00 54.413333
2016-07-01 13:00:00 55.526667
2016-07-01 13:05:00 56.120000
2016-07-01 13:10:00 55.620000
2016-07-01 13:15:00 56.420000
2016-07-01 13:20:00 51.893333
2016-07-01 13:25:00 74.451613
2016-07-01 13:30:00 54.898551
2016-07-01 13:35:00 NaN
2016-07-01 13:40:00 63.355140
2016-07-01 13:45:00 61.000000
Freq: 5T, dtype: float64
Where, for example, the first discontinuous event is from 5:40 to 7:40.