1
我已經開始學習statsmodels包,並且無法使用arima實現基本預測。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)
在此之前,我試圖
df = make_df(filename_data)
y = np.array(df[rev_col])
x = np.array(df[date_col])
y = pd.TimeSeries(y, index=x)
爲什麼會發生?
日期 - 收入數據看起來不錯:
2014-08-04 59477
2014-08-05 29989
2014-08-06 29989
2014-08-07 116116