prophet icon indicating copy to clipboard operation
prophet copied to clipboard

Holidays are all zeros (pandas 1.1.0 breaks holidays)

Open MAFiA303 opened this issue 6 years ago • 4 comments

suddently holidays disappeared and are all zeros. I started a new code following the example on the website and the same problem appeared. I cannot tell what the cause is . here is the code:

df = pd.read_csv('/Users/saad/Desktop/peyton_example.csv')

playoffs = pd.DataFrame({
  'holiday': 'playoff',
  'ds': pd.to_datetime(['2008-01-13', '2009-01-03', '2010-01-16',
                        '2010-01-24', '2010-02-07', '2011-01-08',
                        '2013-01-12', '2014-01-12', '2014-01-19',
                        '2014-02-02', '2015-01-11', '2016-01-17',
                        '2016-01-24', '2016-02-07']),
  'lower_window': 0,
  'upper_window': 1,
})
superbowls = pd.DataFrame({
  'holiday': 'superbowl',
  'ds': pd.to_datetime(['2010-02-07', '2014-02-02', '2016-02-07']),
  'lower_window': 0,
  'upper_window': 1,
})
holidays = pd.concat((playoffs, superbowls))

m = Prophet(holidays=holidays)
forecast = m.fit(df).predict(future)


## optional
m.add_country_holidays(country_name='US')



MAFiA303 avatar Aug 09 '20 12:08 MAFiA303

Duplicate of #1607 . This is an issue with pandas 1.1.0. Downgrade pandas to a version <1.1.0 (e.g. 1.0.5) and it should work again.

gentnm avatar Aug 09 '20 17:08 gentnm

@gentnm Thank you for this. Had same problem on a new machine but working well on another.

collinsuzebu avatar Aug 09 '20 18:08 collinsuzebu

Ok I just pushed a fix in 75ec9df . Old versions of pandas allow looking up a python date object in a pandas date index, but starting in pd 1.1.0 it seems you can only look up a pandas timestamp. We'll push this to pypi, but in the meantime the workaround is to downgrade pandas as described above.

bletham avatar Aug 14 '20 18:08 bletham

This is now fixed in v0.7 that was just pushed to pypi.

bletham avatar Sep 03 '20 01:09 bletham