有没有办法将熊猫的每日预测转换为每小时预测

时间:2019-10-20 05:11:23

标签: python pandas datetime time-series

#df_test.head(3)

    ID      Datetime
0  18288    26-09-2014 00:00
1  18289    26-09-2014 01:00
2  18290    26-09-2014 02:00

#df_test['Datetime'] = pd.to_datetime(df_test['Datetime'])
#df_test = df_test.set_index('Datetime')

Datetime             ID
2014-09-26 00:00:00 18288
2014-09-26 01:00:00 18289
2014-09-26 02:00:00 18290

# Converting to daily mean 
df_test_daily = df_test.resample('D').mean() 

# model.predict(df_test_daily)

将交通量预测计算为每日数据后,我们如何将其转换为小时数预测。

1 个答案:

答案 0 :(得分:0)

只需将D更改为H。

# Converting to daily mean 
df_test_daily = df_test.resample('H').mean()

此处有更多信息:https://pandas.pydata.org/pandas-docs/stable/user_guide/timeseries.html#dateoffset-objects