简体   繁体   中英

how to perform X-12-ARIMA statsmodels on resampled dataframe

I follow this example of statsmodels X-12-ARIMA implementation, and in my case I have the dataframe that looks like

668  2000/01/28 20:00:00  1.476667
669  2000/01/28 21:00:00  1.715498
670  2000/01/28 22:00:00  1.713599
671  2000/01/28 23:00:00  1.733763

that I need analyze, I have two months of data, so I'de like to resample monthly. I use this peace of code :

df.index=pd.to_datetime(df.ts)
df=df.resample('M')
print df
res = sm.tsa.x13_arima_select_order(df.value)

I'm not sure to understand the output of print :

DatetimeIndexResampler [freq=<MonthEnd>, axis=0, closed=right, label=right, convention=start, base=0]

and the following bug of the last line of code :

File "home/.virtualenvs/local/lib/python2.7/site-packages/statsmodels-0.8.0-py2.7-linux-x86_64.egg/statsmodels/tsa/x13.py", line 412, in x13_arima_analysis raise ValueError("start and freq cannot be none if endog is not " ValueError: start and freq cannot be none if endog is not a pandas object

I guess the problem is in my dataset, but I can't figure out what exactly went wrong. Could you help me understand the problem, and how I can proceed to treat this error?

Try this:

df.ts = pd.to_datetime(df.ts)
res = df.set_index('ts')['value'].resample('M').apply(sm.tsa.x13_arima_select_order)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM