我正在尝试在 Python 中拟合时间序列自回归模型输入DF: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 DF的索引:DatetimeIndex(['2018-09-20 18:00:00'.......]模型: 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_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'我检查了“last_hour”的类型print (type(last_hour))<class 'pandas.tseries.index.DatetimeIndex'>有关如何纠正此问题的任何建议。
添加回答
举报
0/150
提交
取消