diff --git a/doc/source/whatsnew/v1.0.0.rst b/doc/source/whatsnew/v1.0.0.rst index 48c1173a372a7..78ebdb985edad 100644 --- a/doc/source/whatsnew/v1.0.0.rst +++ b/doc/source/whatsnew/v1.0.0.rst @@ -409,6 +409,9 @@ Other - Bug in :meth:`Series.diff` where a boolean series would incorrectly raise a ``TypeError`` (:issue:`17294`) - :meth:`Series.append` will no longer raise a ``TypeError`` when passed a tuple of ``Series`` (:issue:`28410`) - Fix corrupted error message when calling ``pandas.libs._json.encode()`` on a 0d array (:issue:`18878`) +- Fix :class:`AbstractHolidayCalendar` to return correct results for + years after 2030 (now goes up to 2200) (:issue:`27790`) + .. _whatsnew_1000.contributors: diff --git a/pandas/tests/groupby/test_categorical.py b/pandas/tests/groupby/test_categorical.py index 5391cb5ce821f..0e30b104bf9d2 100644 --- a/pandas/tests/groupby/test_categorical.py +++ b/pandas/tests/groupby/test_categorical.py @@ -784,7 +784,8 @@ def test_categorical_no_compress(): def test_sort(): - # http://stackoverflow.com/questions/23814368/sorting-pandas-categorical-labels-after-groupby # noqa: E501 + # http://stackoverflow.com/questions/23814368/sorting-pandas- + # categorical-labels-after-groupby # This should result in a properly sorted Series so that the plot # has a sorted x axis # self.cat.groupby(['value_group'])['value_group'].count().plot(kind='bar') diff --git a/pandas/tests/tseries/holiday/test_calendar.py b/pandas/tests/tseries/holiday/test_calendar.py index 79c28942769f0..c122f92ed228c 100644 --- a/pandas/tests/tseries/holiday/test_calendar.py +++ b/pandas/tests/tseries/holiday/test_calendar.py @@ -2,7 +2,7 @@ import pytest -from pandas import DatetimeIndex +from pandas import DatetimeIndex, offsets, to_datetime import pandas.util.testing as tm from pandas.tseries.holiday import ( @@ -10,6 +10,7 @@ Holiday, Timestamp, USFederalHolidayCalendar, + USLaborDay, USThanksgivingDay, get_calendar, ) @@ -81,3 +82,19 @@ def test_calendar_observance_dates(): def test_rule_from_name(): us_fed_cal = get_calendar("USFederalHolidayCalendar") assert us_fed_cal.rule_from_name("Thanksgiving") == USThanksgivingDay + + +def test_calendar_2031(): + # See gh-27790 + # + # Labor Day 2031 is on September 1. Saturday before is August 30. + # Next working day after August 30 ought to be Tuesday, September 2. + + class testCalendar(AbstractHolidayCalendar): + rules = [USLaborDay] + + cal = testCalendar() + workDay = offsets.CustomBusinessDay(calendar=cal) + Sat_before_Labor_Day_2031 = to_datetime("2031-08-30") + next_working_day = Sat_before_Labor_Day_2031 + 0 * workDay + assert next_working_day == to_datetime("2031-09-02") diff --git a/pandas/tseries/holiday.py b/pandas/tseries/holiday.py index 1654163d2a9e0..eb8600031439f 100644 --- a/pandas/tseries/holiday.py +++ b/pandas/tseries/holiday.py @@ -346,7 +346,7 @@ class AbstractHolidayCalendar(metaclass=HolidayCalendarMetaClass): rules = [] # type: List[Holiday] start_date = Timestamp(datetime(1970, 1, 1)) - end_date = Timestamp(datetime(2030, 12, 31)) + end_date = Timestamp(datetime(2200, 12, 31)) _cache = None def __init__(self, name=None, rules=None):