neuralforecast icon indicating copy to clipboard operation
neuralforecast copied to clipboard

Compatibility with Pandas >= 2.0

Open lecramex opened this issue 2 years ago • 4 comments

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

lecramex avatar Mar 11 '24 17:03 lecramex

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.

elephaint avatar Mar 11 '24 17:03 elephaint

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

lecramex avatar Mar 12 '24 07:03 lecramex

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

jmoralez avatar Mar 12 '24 12:03 jmoralez

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

Not yet

elephaint avatar Mar 19 '24 22:03 elephaint