JoaquinAmatRodrigo / skforecast

Time series forecasting with machine learning models
https://skforecast.org
BSD 3-Clause "New" or "Revised" License
996 stars 113 forks source link

ForecasterSarimax - AttributeError: 'PeriodIndex' object has no attribute 'step' #666

Closed DeLuke84 closed 1 month ago

DeLuke84 commented 2 months ago

Hello,

I'm facing an issue within the ForecasterSarimax implemetation.

Im passing a time series with IndexType 'pd.PeriodIndex' and got the exception mentioned in the title.

Its caused by ForecasterSarimax.py, lines 298-301:

if isinstance(y.index, pd.DatetimeIndex): self.index_freq = y.index.freqstr else: self.index_freq = y.index.step

I did some research and it doesnt seem that any kind of panda index has a step attribute at all.

Any advice on this?

JavierEscobarOrtiz commented 2 months ago

Hello @DeLuke84,

Skforecast only allows pd.RangeIndex and pd.DatetimeIndex.

If you want a date-based index, I recommend you create the index with the pd.date_range function:

https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.date_range.html

Hope it helps!