Fitting ARMA model to time series indexed by time in python

Viewed 3773

I am trying to fit an ARMA model to a time series stored in a pandas dataframe. The dataframe has one column of values of type numpy.float64 named "val" and an index of pandas timestamps. The timestamps are in the "Year-Month-Day Hour:Minute:Second" format. I understand that the following code:

from statsmodels.tsa.arima_model import ARMA
model = ARMA(df["val"], (1,0))

gives me the error message:

ValueError: Given a pandas object and the index does not contain dates

because I have not formatted the timestamps correctly. How can I index my dataframe so that the ARMA method accepts it while retaining my date and time information?

1 Answers
Related