使用没有日期的 Statsmodel ARIMA
Using Statsmodel ARIMA without dates
我有时间序列,但没有任何日期。
我知道采集到的数据是均匀分布的
Statsmodel ARIMA 假定我必须有日期并抛出以下错误:
ValueError: Given a pandas object and the index does not contain dates
是否无法在不知道日期的情况下使用 ARIMA?
我的数据由一个 .csv 文件组成,如下所示:
286
276
...
239
236
为了出于某种原因使用 "statsmodels.tsa.arima_model" 包,我仍然不清楚(因为据我所知,ARIMA 应该能够在没有指定日期的情况下运行)你的 DataFrame 索引必须在 pandas.DatetimeIndex格式。
我创建了一天频率如下的虚拟日期:
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')
我有时间序列,但没有任何日期。
我知道采集到的数据是均匀分布的
Statsmodel ARIMA 假定我必须有日期并抛出以下错误:
ValueError: Given a pandas object and the index does not contain dates
是否无法在不知道日期的情况下使用 ARIMA?
我的数据由一个 .csv 文件组成,如下所示:
286
276
...
239
236
为了出于某种原因使用 "statsmodels.tsa.arima_model" 包,我仍然不清楚(因为据我所知,ARIMA 应该能够在没有指定日期的情况下运行)你的 DataFrame 索引必须在 pandas.DatetimeIndex格式。
我创建了一天频率如下的虚拟日期:
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')