Skip to content

BUG: Increase range of dates for holiday calculations #27790

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 16 commits into from
Oct 24, 2019
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions doc/source/whatsnew/v0.25.2.rst
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ Other
- Compatibility with Python 3.8 in :meth:`DataFrame.query` (:issue:`27261`)
- Fix to ensure that tab-completion in an IPython console does not raise
warnings for deprecated attributes (:issue:`27900`).
- Fix :class:`AbstractHolidayCalendar` to return correct results for
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you move this to v1.0.0?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved.

years after 2030 (now goes up to 2200) (:issue:`27790`)


.. _whatsnew_0.252.contributors:

Expand Down
3 changes: 2 additions & 1 deletion pandas/tests/groupby/test_categorical.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
19 changes: 18 additions & 1 deletion pandas/tests/tseries/holiday/test_calendar.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@

import pytest

from pandas import DatetimeIndex
from pandas import DatetimeIndex, offsets, to_datetime
import pandas.util.testing as tm

from pandas.tseries.holiday import (
AbstractHolidayCalendar,
Holiday,
Timestamp,
USFederalHolidayCalendar,
USLaborDay,
USThanksgivingDay,
get_calendar,
)
Expand Down Expand Up @@ -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")
2 changes: 1 addition & 1 deletion pandas/tseries/holiday.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down