一、我想要預測 excel data frame 的資料,來產出幾天後的預測資料
二、使用 arima 來預測,但報錯——
only integers, slices (:
), ellipsis (...
), numpy.newaxis (None
) and integer or boolean arrays are valid indices
import pandas as pd
from statsmodels.tsa.arima_model import ARIMA
import warnings
warnings.filterwarnings('ignore')
df = pd.read_excel('01.xlsx',header=0,parse_dates=[0],index_col=0,squeeze=True)
d = pd.date_range(df.index.min(),df.index.max())
df = df[['Close']]
df1 = pd.Series(df['Close'],d)
df1 = df1.dropna()
r = ARIMA(df1,(1,2,0))
model_fit = r.fit(disp=0)
pred = model_fit.predict(start = '2012-07-31', end = '2012-09-01' , typ='levels')
print(pred)
請問該如何解決呢?謝謝!
parse_dates=True 才對吧。
df = pd.read_excel('01.xlsx',header=0,parse_dates=True,index_col=0,squeeze=True)