如何更改熊猫重新采样评估的时间段?

时间:2019-05-16 15:40:12

标签: python pandas series

基于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:0000: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

0 个答案:

没有答案