Handle holidays with subdaily data

This commit is contained in:
bl 2017-07-04 20:32:42 -07:00
parent b93f71540d
commit ec497ffba8
2 changed files with 12 additions and 1 deletions

View file

@ -311,7 +311,8 @@ class Prophet(object):
# Holds columns of our future matrix.
expanded_holidays = defaultdict(lambda: np.zeros(dates.shape[0]))
# Makes an index so we can perform `get_loc` below.
row_index = pd.DatetimeIndex(dates)
# Strip to just dates.
row_index = pd.DatetimeIndex(dates.apply(lambda x:x.date()))
for _ix, row in self.holidays.iterrows():
dt = row.ds.date()

View file

@ -326,3 +326,13 @@ class TestProphet(TestCase):
m = Prophet()
m.fit(DATA)
self.assertNotIn('daily', m.seasonalities)
def test_subdaily_holidays(self):
holidays = pd.DataFrame({
'ds': pd.to_datetime(['2017-01-02']),
'holiday': ['new_years'],
})
m = Prophet(holidays=holidays)
m.fit(DATA2)
fcst = m.predict()
self.assertEqual(sum(fcst['new_years'] == 0), 575)