fastai / fastai

The fastai deep learning library
http://docs.fast.ai
Apache License 2.0
26.18k stars 7.55k forks source link

error (fatai 1.61) #3906

Open jsgaston opened 1 year ago

jsgaston commented 1 year ago

hi

at this moment, I cant ask in the forum

I get this error:

in test   
    fastai.tabular.add_datepart(df2, 'time', drop='True')
  File "C:\Users\jsgas\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\fastai\tabular\transform.py", line 63, in add_datepart
    for n in attr: df[prefix + n] = getattr(field.dt, n.lower())
AttributeError: 'DatetimeProperties' object has no attribute 'week'

does any one know whats this?

the code looks like this:


                date_change = '%Y-%m-%d %H:%M:%s'

                # Create a new date column from the index
                #df2['time'] = df2.index

                # Perform the date type change
                #df2['time'] = pd.to_datetime(df2['time'], format=date_change)

                # Create a variable that is the date column
                #Dates = df2['time']
                #data2.drop(["dividends"])
                data=pd.DataFrame(data2)
                data.rename(columns={'date':'time'},inplace=True)
                data.dropna(axis='index',inplace=True)
                precio_ultimo=data.iloc[-1,4]
                #print("datassssssssssssss",data)
                from ta import add_all_ta_features
                data = add_all_ta_features(data, "open", "high", "low", "close", "volume", fillna=True, vectorized=True)

                print("data", data)

                # Library that does date factors
                import fastai.tabular
                from fastai.tabular import add_cyclic_datepart, add_datepart

                ##########################

                ######################

                # Define the date parts
                fastai.tabular.add_datepart(data, 'time', drop='True')

                # Ensure the correct format
                data['time'] = pd.to_datetime(data.index.values, format=date_change)

                # Add the date parts
                fastai.tabular.add_cyclic_datepart(data, 'time', drop='True')

I don't have a clue of whats this ... today I reinstalled windows, and this error appears. what can it be?

Mawaz commented 1 year ago

Hi, have you checked the version of Pandas that is currently installed? Maybe upgrading the Pandas version can resolve the issue as it could be that the DatetimeProperties object is outdated or incompatible with the version of Fastai you are using.

Also, in current version 2.7.12 the import for add_datepart is with fastai.tabular.core or fastai.tabular.all