TypeError:python上的=:“slice”和“int”的操作数类型不受支持

2021-02-25 21:29:50 发布

您现在位置:Python中文网/ 问答频道 /正文

你好,我试着做时间序列分析,但我得到了这个回溯,谁能帮我?在

Python版本:3.6.7

数据集:https://www.kaggle.com/neuromusic/avocado-prices

# ARIMA LİBRARY
from statsmodels.tsa.arima_model import ARIMA
from pandas import datetime

# fit model
model = ARIMA(ts, order=(1,0,1)) # (ARMA) = (1,0,1)
model_fit = model.fit(disp=0)

# predict
start_index = datetime(2015, 1, 4)
end_index = datetime(2018, 3, 25)
forecast = model_fit.predict(start=start_index, end=end_index)

# visualization
plt.figure(figsize=(22,10))
plt.plot(data.date,data.avprice,label = "original")
plt.plot(forecast,label = "predicted")
plt.title("Time Series Forecast")
plt.xlabel("Date")
plt.ylabel("Mean Temperature")
plt.legend()
plt.show()

回溯:

^{pr2}$