Python ValueError: Start must be in dates. Received 2016-01-01 | 2016-01-01 00:00:00

I use statsmodels.tsa.statespace.sarimax for forecasting. Here is my code

pprint(list(rolmean_df.index)[0]) >> datetime.date(2015, 5, 19) mod = sm.tsa.statespace.SARIMAX(rolmean_df['IC_10_diff'], trend='n', order=(2,1,2)) results = mod.fit() s = results.get_prediction(start = pd.to_datetime('2016-01-01').date(), dynamic= False) >> ValueError: Start must be in dates. Got 2016-01-01 | 2016-01-01 00:00:00 

I am not sure if my "start" format is incorrect or something else is not working.

+5
source share
2 answers

From the document: http://www.statsmodels.org/dev/generated/statsmodels.tsa.statespace.sarimax.SARIMAXResults.html

  • get_forecast ([steps]) Forecast out of selection
  • get_prediction ([start, end, dynamic, exog]) Forecasting inside the sample and outside the forecasting sample

So, โ€œStart must be in datesโ€ means that the start must be in your dataset.

If you want to use the model for forecase, use get_forecast ().

+7
source

I have the same problem with you a few days ago. Now I have a reasonable explanation.

I think the start date and end date of this function depends on your data set.

For example, the first time I want the start date to be "2017-10-01", but this date is not in my data. And then "2017-12-01" is the value of the start date, the file can be compiled, because this date is in my data set.

+1
source

All Articles