我试图在Python中拟合时间序列自回归模型
输入数据框:code test_col
2018-09-20 18:00:00 10
2018-09-20 19:00:00 20
2018-09-20 20:00:00 21
2018-09-20 21:00:00 17
2018-09-20 22:00:00 7
测向索引:
^{pr2}$
型号:mod = AR(DF[test_col])
res = mod.fit(maxlag= 20, ic= 'aic')
last_hour = df.index[[len(df)-1]]
pred = res.predict(start=last_hour[0],end = last_hour[0] )
last\u hour=>;从要预测的索引中获取最新的时间戳
错误:File "pandas/tslib.pyx", line 1280, in pandas.tslib._Timestamp.__sub__ (pandas/tslib.c:23914)
TypeError: descriptor '__sub__' requires a 'datetime.datetime' object but received a 'int'
我查过“最后一小时”的类型print (type(last_hour))
关于如何纠正这个问题有什么建议吗。在