Skip to content

Commit b1eb97b

Browse files
rhstantonWillAyd
authored andcommitted
BUG: Increase range of dates for holiday calculations (#27790)
1 parent da1401b commit b1eb97b

File tree

4 files changed

+24
-3
lines changed

4 files changed

+24
-3
lines changed

doc/source/whatsnew/v1.0.0.rst

+3
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,9 @@ Other
413413
- Bug in :meth:`Series.diff` where a boolean series would incorrectly raise a ``TypeError`` (:issue:`17294`)
414414
- :meth:`Series.append` will no longer raise a ``TypeError`` when passed a tuple of ``Series`` (:issue:`28410`)
415415
- Fix corrupted error message when calling ``pandas.libs._json.encode()`` on a 0d array (:issue:`18878`)
416+
- Fix :class:`AbstractHolidayCalendar` to return correct results for
417+
years after 2030 (now goes up to 2200) (:issue:`27790`)
418+
416419

417420
.. _whatsnew_1000.contributors:
418421

pandas/tests/groupby/test_categorical.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -784,7 +784,8 @@ def test_categorical_no_compress():
784784

785785
def test_sort():
786786

787-
# http://stackoverflow.com/questions/23814368/sorting-pandas-categorical-labels-after-groupby # noqa: E501
787+
# http://stackoverflow.com/questions/23814368/sorting-pandas-
788+
# categorical-labels-after-groupby
788789
# This should result in a properly sorted Series so that the plot
789790
# has a sorted x axis
790791
# self.cat.groupby(['value_group'])['value_group'].count().plot(kind='bar')

pandas/tests/tseries/holiday/test_calendar.py

+18-1
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@
22

33
import pytest
44

5-
from pandas import DatetimeIndex
5+
from pandas import DatetimeIndex, offsets, to_datetime
66
import pandas.util.testing as tm
77

88
from pandas.tseries.holiday import (
99
AbstractHolidayCalendar,
1010
Holiday,
1111
Timestamp,
1212
USFederalHolidayCalendar,
13+
USLaborDay,
1314
USThanksgivingDay,
1415
get_calendar,
1516
)
@@ -81,3 +82,19 @@ def test_calendar_observance_dates():
8182
def test_rule_from_name():
8283
us_fed_cal = get_calendar("USFederalHolidayCalendar")
8384
assert us_fed_cal.rule_from_name("Thanksgiving") == USThanksgivingDay
85+
86+
87+
def test_calendar_2031():
88+
# See gh-27790
89+
#
90+
# Labor Day 2031 is on September 1. Saturday before is August 30.
91+
# Next working day after August 30 ought to be Tuesday, September 2.
92+
93+
class testCalendar(AbstractHolidayCalendar):
94+
rules = [USLaborDay]
95+
96+
cal = testCalendar()
97+
workDay = offsets.CustomBusinessDay(calendar=cal)
98+
Sat_before_Labor_Day_2031 = to_datetime("2031-08-30")
99+
next_working_day = Sat_before_Labor_Day_2031 + 0 * workDay
100+
assert next_working_day == to_datetime("2031-09-02")

pandas/tseries/holiday.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ class AbstractHolidayCalendar(metaclass=HolidayCalendarMetaClass):
346346

347347
rules = [] # type: List[Holiday]
348348
start_date = Timestamp(datetime(1970, 1, 1))
349-
end_date = Timestamp(datetime(2030, 12, 31))
349+
end_date = Timestamp(datetime(2200, 12, 31))
350350
_cache = None
351351

352352
def __init__(self, name=None, rules=None):

0 commit comments

Comments
 (0)