Skip to content

Commit f02965b

Browse files
authored
Fix bug in calculation of holidays
Closes pandas-dev#31415
1 parent b1214af commit f02965b

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

pandas/tseries/holiday.py

+11-10
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,18 +407,18 @@ 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-
416-
if holidays is None:
417-
holidays = rule_holidays
418-
else:
419-
holidays = holidays.append(rule_holidays)
420-
415+
holidays.append(rule.dates(start, end, return_name=True))
416+
417+
if holidays:
418+
holidays = concat(holidays)
419+
else:
420+
holidays = Series(index=DatetimeIndex([]), dtype=object)
421+
421422
self._cache = (start, end, holidays.sort_index())
422423

423424
holidays = self._cache[2]

0 commit comments

Comments
 (0)