基于https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.resample.html的示例,我尝试使用熊猫resample
index = pd.date_range('1/1/2000', periods=9, freq='T')
series = pd.Series(range(9), index=index)
series.resample('3T').sum()
#Output:
#2000-01-01 00:00:00 3
#2000-01-01 00:03:00 12
#2000-01-01 00:06:00 21
重新采样功能仅在index
(此处是从00:00:00
到00:08:00
)的时间段上运行。如何更改resamples
评估的时间段(例如from = '1999-12-31 23:54:00', to = '2000-01-01 00:15:00')
?
因此,所需的输出将是:
#1999-12-31 23:54:00 NaN
#1999-12-31 23:57:00 NaN
#2000-01-01 00:00:00 3
#2000-01-01 00:03:00 12
#2000-01-01 00:06:00 21
#2000-01-01 00:09:00 NaN
#2000-01-01 00:12:00 NaN
#2000-01-01 00:15:00 NaN