时间序列 | 重采样及频率转换resample有一个类似于groupby的API,调用resample可以分组数据,然后会调用一个聚合函数:
>>> ts.resample('M').mean()
2000-01-31 0.053476 ('5min').sum()
>>> ts.resample('5min', closed = 'left').sum()
>>> ts.resample('5min', closed = 'left' 但标签需要取最左边即09:00:00
>>> ts.resample('5min', closed = 'right').sum()
>>> ts.resample('5min', closed = ' >>> ts.resample('5min', closed = 'right', label = 'right').sum()
2020-01-01 09:00:00 0
2020-01-01 09:05:00 15
Freq: 5T, dtype: int64
>>> ts.resample('5min', closed='right',label='right', loffset