prophet icon indicating copy to clipboard operation
prophet copied to clipboard

prophet_model.plot_components throws AttributeError: 'DatetimeIndex' object has no attribute 'weekday_name'

Open clstaudt opened this issue 6 years ago • 6 comments

prophet: latest commit from master pandas: 1.0

/DataScience101/prophet/python/fbprophet/forecaster.py:418: FutureWarning:

The pandas.datetime class is deprecated and will be removed from pandas in a future version. Import from datetime module instead.

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-16-57f78049eeb8> in <module>
----> 1 prophet_model.plot_components(ts_forecast);

~/DataScience101/prophet/python/fbprophet/forecaster.py in plot_components(self, fcst, uncertainty, plot_cap, weekly_start, yearly_start, figsize)
   1579             m=self, fcst=fcst, uncertainty=uncertainty, plot_cap=plot_cap,
   1580             weekly_start=weekly_start, yearly_start=yearly_start,
-> 1581             figsize=figsize
   1582         )

~/DataScience101/prophet/python/fbprophet/plot.py in plot_components(m, fcst, uncertainty, plot_cap, weekly_start, yearly_start, figsize)
    159             if plot_name == 'weekly' or m.seasonalities[plot_name]['period'] == 7:
    160                 plot_weekly(
--> 161                     m=m, name=plot_name, ax=ax, uncertainty=uncertainty, weekly_start=weekly_start
    162                 )
    163             elif plot_name == 'yearly' or m.seasonalities[plot_name]['period'] == 365.25:

~/DataScience101/prophet/python/fbprophet/plot.py in plot_weekly(m, ax, uncertainty, weekly_start, figsize, name)
    289     df_w = seasonality_plot_df(m, days)
    290     seas = m.predict_seasonal_components(df_w)
--> 291     days = days.weekday_name
    292     artists += ax.plot(range(len(days)), seas[name], ls='-',
    293                     c='#0072B2')

AttributeError: 'DatetimeIndex' object has no attribute 'weekday_name'

clstaudt avatar Feb 03 '20 17:02 clstaudt

Just hit the exact same error when doing a 30 min forecast and running m.plot_components(forecast)

pandas==1.0.0 fbprophet==0.5

both pip installed python 3.7.4

voglster avatar Feb 03 '20 18:02 voglster

I was able to fix the problem just by modifying in C:\Users\XXX\AppData\Local\Continuum\anaconda3\Lib\site-packages\fbprophet I open plot.py line 288 and I just commented that line and it run without problem so far

Jgonzalezh avatar Feb 03 '20 19:02 Jgonzalezh

This is the same as #1304; basically there is an incompatibility with pandas=1.0.0. See that issue for how to fix it for now, and we'll push a compatible version to pypi as soon as possible.

I'm going to close this to concentrate discussion in #1304.

bletham avatar Feb 03 '20 20:02 bletham

How soon can you commit a fix to master? I'd rather work with pandas 1.0 and a development version of prophet than downgrade pandas.

clstaudt avatar Feb 03 '20 23:02 clstaudt

@clstaudt the fix is committed to master as of a few hours ago!

bletham avatar Feb 04 '20 00:02 bletham

Thank you!

clstaudt avatar Feb 04 '20 11:02 clstaudt