Nixtla / neuralforecast

Scalable and user friendly neural :brain: forecasting algorithms.
https://nixtlaverse.nixtla.io/neuralforecast
Apache License 2.0
2.75k stars 316 forks source link

Compatibility with Pandas >= 2.0 #925

Open lecramex opened 4 months ago

lecramex commented 4 months ago

Hello,

While working with neuralforecast 1.6.4 and pandas > 2.0 I found the error when calling neuralforecast.utils.augment_calendar_df:

'DatetimeIndex' object has no attribute 'week'.

This is because this functions calls:

https://github.com/Nixtla/neuralforecast/blob/4e9b721bbbcfb1b870c9fd5ab039c9ea9cb74c10/neuralforecast/utils.py#L360

Which is using index.week, but DatetimeIndex.week has been deprecated since pandas 1.1.0, to solve this you should replace it by:

        return (index.isocalendar().week  - 1) / 52.0 - 0.5
elephaint commented 4 months ago

Thanks, good point. I think it should be index.dt.isocalendar().week, i.e. first need to access the .dt attribute. I'll have a pass through our code and see if there are other such occurences, so we can fix it everywhere.

lecramex commented 4 months ago

Thanks @elephaint do you have any idea when this will available in a release ?

jmoralez commented 4 months ago

This may be a good opportunity to implement this in utilsforecast and add support for polars as well.

elephaint commented 4 months ago

Thanks @elephaint do you have any idea when this will available in a release ?

Not yet