Skip to content

Commit a453ce4

Browse files
dhirschfeldDavid Hirschfeld
authored and
David Hirschfeld
committed
Fix bug in calculation of holidays
Closes pandas-dev#31415
1 parent 761bceb commit a453ce4

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

pandas/tseries/holiday.py

+9-8
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@
77

88
from pandas.errors import PerformanceWarning
99

10-
from pandas import DateOffset, Series, Timestamp, date_range
11-
10+
from pandas import (
11+
DateOffset, DatetimeIndex, Series, Timestamp, concat, date_range,
12+
)
1213
from pandas.tseries.offsets import Day, Easter
1314

1415

@@ -406,17 +407,17 @@ def holidays(self, start=None, end=None, return_name=False):
406407
start = Timestamp(start)
407408
end = Timestamp(end)
408409

409-
holidays = None
410+
holidays = []
410411
# If we don't have a cache or the dates are outside the prior cache, we
411412
# get them again
412413
if self._cache is None or start < self._cache[0] or end > self._cache[1]:
413414
for rule in self.rules:
414-
rule_holidays = rule.dates(start, end, return_name=True)
415+
holidays.append(rule.dates(start, end, return_name=True)
415416

416-
if holidays is None:
417-
holidays = rule_holidays
418-
else:
419-
holidays = holidays.append(rule_holidays)
417+
if holidays:
418+
holidays = concat(holidays)
419+
else:
420+
holidays = Series(index=DatetimeIndex([]), dtype=object)
420421

421422
self._cache = (start, end, holidays.sort_index())
422423

0 commit comments

Comments
 (0)