简体   繁体   中英

Using Statsmodel ARIMA without dates

I have a time series but I do not have any Dates.

I know that the collected data is evenly spaced.

Statsmodel ARIMA assumes that I must have dates and throws the following error:

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

Is it not possible to utilize ARIMA without knowing the dates?

My data consists of a single .csv file as follows:

286
276
...
239
236

In order to use the "statsmodels.tsa.arima_model" package for whatever reason still not clear to me (since ARIMA should be able to operate without specified dates as far as I understand) your DataFrame index must be in pandas.DatetimeIndex format.

I have created dummy dates with a day of frequency as follows:

my_data = pd.read_csv('data_2018.csv', header=None)
my_data = my_data.values.flatten()

# create dummy dates for the arima modules....
dates = pd.date_range('1900-1-1', periods=len(my_data), freq='D')
# add the dates and the data to a new dataframe
ts = pd.DataFrame({'dates': dates, 'data': my_data})
# set the dataframe index to be the dates column
ts = ts.set_index('dates')

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