我已经开始学习statsmodels包,无法使用arima实现基本预测。在
错误是
ValueError: Given a pandas object and the index does not contain dates
我正在尝试这个版本:
df = make_df(filename_data)
y = []
x = []
# here I am preparing day by day sequence as that I have inconsistent data and I set 0 to NAN values
start_date = df[date_col].min()
end_date = df[date_col].max()
while start_date <= end_date:
x.append(start_date)
try:
y.append(
df[df[date_col] == start_date][rev_col].values[0])
except:
y.append(0)
start_date += datetime.timedelta(days=1)
y = np.array(y)
x = np.array(x)
y = pd.TimeSeries(y, index=x)
print(y)
arma_mod = sm.tsa.ARMA(y, order=(2,2))
arma_res = arma_mod.fit(trend='nc', disp=-1)
在那之前我试过了
^{pr2}$为什么会这样?在
日期收入数据看起来不错:
2014-08-04 59477
2014-08-05 29989
2014-08-06 29989
2014-08-07 116116
您只需使用as_matrix()转换数据帧。在
示例工作代码:
由于statsmodels有许多未解决的问题,它只能暂时帮助您。在
相关问题 更多 >
编程相关推荐