Resample Daily Pandas Timeseries With Start At Time Other Than Midnight
I have a pandas timeseries of 10-min freqency data and need to find the maximum value in each 24-hour period. However, this 24-hour period needs to start each day at 5AM - not the
Solution 1:
The base
keyword can do the trick (see docs):
s.resample('24h', base=5)
Eg:
In [35]: idx = pd.date_range('2012-01-01 00:00:00', freq='5min', periods=24*12*3)
In [36]: s = pd.Series(np.arange(len(idx)), index=idx)
In [38]: s.resample('24h', base=5)
Out[38]:
2011-12-3105:00:0029.52012-01-0105:00:00203.52012-01-0205:00:00491.52012-01-0305:00:00749.5
Freq: 24H, dtype: float64
Solution 2:
I've just spotted an answered question which didn't come up on Google or Stack Overflow previously:
Resample hourly TimeSeries with certain starting hour
This uses the base parameter, which looks like an addition subsequent to Wes McKinney's Python for Data Analysis. I've given the parameter a go and it seems to do the trick.
Post a Comment for "Resample Daily Pandas Timeseries With Start At Time Other Than Midnight"