小编Ell*_*oke的帖子

将 ARMA 模型拟合到 Python 中按时间索引的时间序列

我正在尝试将 ARMA 模型拟合到存储在 Pandas 数据帧中的时间序列。数据框有一列名为“val”的 numpy.float64 类型的值和一个熊猫时间戳索引。时间戳采用“年-月-日小时:分钟:秒”格式。我了解以下代码:

from statsmodels.tsa.arima_model import ARMA
model = ARMA(df["val"], (1,0))
Run Code Online (Sandbox Code Playgroud)

给我错误信息:

ValueError: Given a pandas object and the index does not contain dates
Run Code Online (Sandbox Code Playgroud)

因为我没有正确格式化时间戳。如何索引我的数据帧,以便 ARMA 方法在保留我的日期和时间信息的同时接受它?

python statistics time-series pandas statsmodels

4
推荐指数
1
解决办法
3378
查看次数

标签 统计

pandas ×1

python ×1

statistics ×1

statsmodels ×1

time-series ×1