我想以一个以Q时段为中心的P时段的窗口来计算Datetime索引上的值的平均值。
我有一个数据记录秒数的记录
Time Temperature
2017-11-28 22:00:03 58.34
2017-11-28 22:00:05 57.54
2017-11-28 22:00:07 58.18
2017-11-28 22:00:09 58.18
2017-11-28 22:00:12 58.18
我想对5分钟频率之前和之后2.5分钟的值进行分组,并得到如下内容:
Time Temperature
2017-11-28 22:05:00 mean(5 minutes before and after)
2017-11-28 22:10:00 mean(5 minutes before and after)
2017-11-28 22:15:00 mean(5 minutes before and after)
2017-11-28 22:20:00 mean(5 minutes before and after)
2017-11-28 22:25:00 mean(5 minutes before and after)
我正在尝试
hum_sta.set_index('Time').groupby(pd.Grouper(freq='5Min')).rolling("5min").mean()
但是我没有得到想要的东西,只是得到了Multiindex Pandas Dataframe:
Time Time Temperature
2017-11-28 22:00:00 2017-11-28 22:00:03 NaN
2017-11-28 22:00:05 57.94
2017-11-28 22:00:07 57.86
2017-11-28 22:00:09 58.18
2017-11-28 22:00:12 58.18