Split A Series On Time Gaps In Pandas?
Is it possible to split a time series on it's gaps. For example, suppose we had the following: rng2011 = pd.date_range('1/1/2011', periods=72, freq='H') rng2012 = pd.date_range('1/
Solution 1:
Assuming Y is a column in your dataframe, one way is to use diff
and cumsum:
df = DataFrame(Y)
df[1] = df[0].diff() > 600000000000.0 #nanoseconds in ten minutesdf[1] = df[1].cumsum()
df.groupby(1)
Note: If you use the number of nanoseconds in 72 hours it'll split into two groups.
Post a Comment for "Split A Series On Time Gaps In Pandas?"