为了账号安全,请及时绑定邮箱和手机立即绑定

statsmodels中的AR模型

statsmodels中的AR模型

MM们 2021-07-30 18:49:44
我正在尝试在 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'>有关如何纠正此问题的任何建议。
查看完整描述

2 回答

  • 2 回答
  • 0 关注
  • 223 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号