[英]Using Statsmodel and the ARIMA model to forecast but running into issues
[英]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')
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.