@prakhar278 wrote:
Hello friend, I am doing time series forecasting but i am stuck one place.its ValueError: Given a pandas object and the index does not contain dates. why this error occurs? here is my code
con = pymysql.connect(host='10',
port=0000,
user='system',
passwd='hq',
db='reportingl')
cur = "SELECT date(calllocalTime) as datum,count(id) as incoming fromsogedes-db
.odcalls where CAST(callLocalTime AS DATE) between '2015-09-02' and curdate() and LastCampaign in (9807,9808,9809,9810) and dayofweek(callLocalTime) Not in (1) and calltype = 1 and FirstQueue != 0 group by datum" ;data = pd.read_sql_query(cur,con, index_col=None, coerce_float=True, params=None, parse_dates=None)
ts = data['incoming']
ts_log = np.log(ts)expwighted_avg = pd.ewma(ts_log, halflife=12)
plt.plot(ts_log)
plt.plot(expwighted_avg, color='red')ts_log_diff = ts_log - ts_log.shift()
plt.plot(ts_log_diff)
ts_log_diff.dropna(inplace=True)
test_stationarity(ts_log_diff)lag_acf = acf(ts_log_diff, nlags=20)
lag_pacf = pacf(ts_log_diff, nlags=20, method='ols')plt.subplot(121)
plt.plot(lag_acf)
plt.axhline(y=0,linestyle='--',color='gray')
plt.axhline(y=-1.96/np.sqrt(len(ts_log_diff)),linestyle='--',color='gray')
plt.axhline(y=1.96/np.sqrt(len(ts_log_diff)),linestyle='--',color='gray')
plt.title('Autocorrelation Function')plt.subplot(122)
plt.plot(lag_pacf)
plt.axhline(y=0,linestyle='--',color='gray')
plt.axhline(y=-1.96/np.sqrt(len(ts_log_diff)),linestyle='--',color='gray')
plt.axhline(y=1.96/np.sqrt(len(ts_log_diff)),linestyle='--',color='gray')
plt.title('Partial Autocorrelation Function')
plt.tight_layout()model = ARIMA(ts_log, order=[2, 1, 0])
results_AR = model.fit(disp=-1)
plt.plot(ts_log_diff)
plt.plot(results_AR.fittedvalues, color='red')
plt.title('RSS: %.4f'% sum((results_AR.fittedvalues-ts_log_diff)**2))its said model = ARIMA(ts_log, order=[2, 1, 0]) has error
ValueError: Given a pandas object and the index does not contain dates
Posts: 6
Participants: 2