antoinecarme / pyaf

PyAF is an Open Source Python library for Automatic Time Series Forecasting built on top of popular pydata modules.
BSD 3-Clause "New" or "Revised" License
457 stars 73 forks source link

Future Warning regarding DateTime_Functions - series.dt.weekofyear #153

Closed TomKetOS closed 3 years ago

TomKetOS commented 3 years ago

Hello Antoinecarme, thanks a lot for all your work done here. I'm very new in python and programming at all, but thanks to your dokumentation i could start working with forecasting.

I got a FutureWaring as follows:

D:\Python\WPy64-3810\python-3.8.1.amd64\lib\site-packages\pyaf\TS\DateTime_Functions.py:50: FutureWarning:

Series.dt.weekofyear and Series.dt.week have been deprecated. Please use Series.dt.isocalendar().week instead.

I try to modifiy but that seem to make the problem bigger:

class cDateTime_Helper:

def __init__(self):
    pass

def get_week_of_month(self, series):
    lFirstDayOfMonth = series - pd.to_timedelta(series.dt.day - 1, unit='D')
    return series.dt.weekofyear - lFirstDayOfMonth.dt.weekofyear + 1
    #return series.dt.isocalendar().week - lFirstDayOfMonth.dt.isocalendar() + 1

thanks a lot Thomas

antoinecarme commented 3 years ago

Hi @TomKetOS

Thanks for your interest in PAF.

Your fix is OK.

The warning is related to newer versions of python . I try to keep PyAF compatible with newer versions. Latest tested is 3.7.

There is a work in progress around that :

https://github.com/antoinecarme/pyaf/issues/149

antoinecarme commented 3 years ago

You probably need this :

def get_week_of_month(self, series):
    lFirstDayOfMonth = series - pd.to_timedelta(series.dt.day - 1, unit='D')
    return series.dt.isocalendar().week - lFirstDayOfMonth.dt.isocalendar().week + 1
antoinecarme commented 3 years ago

Fixed.