Skip to content

Holiday rename; Juneteenth start_date #44576

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 5 commits into from
Nov 29, 2021
Merged
Show file tree
Hide file tree
Changes from all 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
14 changes: 14 additions & 0 deletions doc/source/whatsnew/v1.4.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,8 @@ Other enhancements
- :meth:`Timestamp.isoformat`, now handles the ``timespec`` argument from the base :class:``datetime`` class (:issue:`26131`)
- :meth:`NaT.to_numpy` ``dtype`` argument is now respected, so ``np.timedelta64`` can be returned (:issue:`44460`)
- New option ``display.max_dir_items`` customizes the number of columns added to :meth:`Dataframe.__dir__` and suggested for tab completion (:issue:`37996`)
- Added "Juneteenth National Independence Day" to
``USFederalHolidayCalendar``. See also `Other API changes`_.
- :meth:`.Rolling.var`, :meth:`.Expanding.var`, :meth:`.Rolling.std`, :meth:`.Expanding.std` now support `Numba <http://numba.pydata.org/>`_ execution with the ``engine`` keyword (:issue:`44461`)


Expand Down Expand Up @@ -402,6 +404,18 @@ Other API changes
- :meth:`Index.get_indexer_for` no longer accepts keyword arguments (other than 'target'); in the past these would be silently ignored if the index was not unique (:issue:`42310`)
- Change in the position of the ``min_rows`` argument in :meth:`DataFrame.to_string` due to change in the docstring (:issue:`44304`)
- Reduction operations for :class:`DataFrame` or :class:`Series` now raising a ``ValueError`` when ``None`` is passed for ``skipna`` (:issue:`44178`)
- Changed the ``name`` attribute of several holidays in
``USFederalHolidayCalendar`` to match `official federal holiday
names <https://www.opm.gov/policy-data-oversight/pay-leave/federal-holidays/>`_
specifically:

- "New Year's Day" gains the possessive apostrophe
- "Presidents Day" becomes "Washington's Birthday"
- "Martin Luther King Jr. Day" is now "Birthday of Martin Luther King, Jr."
- "July 4th" is now "Independence Day"
- "Thanksgiving" is now "Thanksgiving Day"
- "Christmas" is now "Christmas Day"
- Added "Juneteenth National Independence Day"
-

.. ---------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/tseries/holiday/test_calendar.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ 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
assert us_fed_cal.rule_from_name("Thanksgiving Day") == USThanksgivingDay


def test_calendar_2031():
Expand Down
24 changes: 14 additions & 10 deletions pandas/tests/tseries/holiday/test_holiday.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,19 +164,23 @@ def test_holiday_dates(holiday, start_date, end_date, expected):
(EasterMonday, "2015-04-06", "2015-04-06"),
(EasterMonday, datetime(2015, 7, 1), []),
(EasterMonday, "2015-04-05", []),
("New Years Day", "2015-01-01", "2015-01-01"),
("New Years Day", "2010-12-31", "2010-12-31"),
("New Years Day", datetime(2015, 7, 1), []),
("New Years Day", "2011-01-01", []),
("July 4th", "2015-07-03", "2015-07-03"),
("July 4th", datetime(2015, 7, 1), []),
("July 4th", "2015-07-04", []),
("New Year's Day", "2015-01-01", "2015-01-01"),
("New Year's Day", "2010-12-31", "2010-12-31"),
("New Year's Day", datetime(2015, 7, 1), []),
("New Year's Day", "2011-01-01", []),
("Independence Day", "2015-07-03", "2015-07-03"),
("Independence Day", datetime(2015, 7, 1), []),
("Independence Day", "2015-07-04", []),
("Veterans Day", "2012-11-12", "2012-11-12"),
("Veterans Day", datetime(2015, 7, 1), []),
("Veterans Day", "2012-11-11", []),
("Christmas", "2011-12-26", "2011-12-26"),
("Christmas", datetime(2015, 7, 1), []),
("Christmas", "2011-12-25", []),
("Christmas Day", "2011-12-26", "2011-12-26"),
("Christmas Day", datetime(2015, 7, 1), []),
("Christmas Day", "2011-12-25", []),
("Juneteenth National Independence Day", "2020-06-19", []),
("Juneteenth National Independence Day", "2021-06-18", "2021-06-18"),
("Juneteenth National Independence Day", "2022-06-19", []),
("Juneteenth National Independence Day", "2022-06-20", "2022-06-20"),
],
)
def test_holidays_within_dates(holiday, start, expected):
Expand Down
19 changes: 13 additions & 6 deletions pandas/tseries/holiday.py
Original file line number Diff line number Diff line change
Expand Up @@ -531,17 +531,17 @@ def merge(self, other, inplace=False):
"Columbus Day", month=10, day=1, offset=DateOffset(weekday=MO(2))
)
USThanksgivingDay = Holiday(
"Thanksgiving", month=11, day=1, offset=DateOffset(weekday=TH(4))
"Thanksgiving Day", month=11, day=1, offset=DateOffset(weekday=TH(4))
)
USMartinLutherKingJr = Holiday(
"Martin Luther King Jr. Day",
"Birthday of Martin Luther King, Jr.",
start_date=datetime(1986, 1, 1),
month=1,
day=1,
offset=DateOffset(weekday=MO(3)),
)
USPresidentsDay = Holiday(
"Presidents Day", month=2, day=1, offset=DateOffset(weekday=MO(3))
"Washington’s Birthday", month=2, day=1, offset=DateOffset(weekday=MO(3))
)
GoodFriday = Holiday("Good Friday", month=1, day=1, offset=[Easter(), Day(-2)])

Expand All @@ -556,16 +556,23 @@ class USFederalHolidayCalendar(AbstractHolidayCalendar):
"""

rules = [
Holiday("New Years Day", month=1, day=1, observance=nearest_workday),
Holiday("New Year's Day", month=1, day=1, observance=nearest_workday),
USMartinLutherKingJr,
USPresidentsDay,
USMemorialDay,
Holiday("July 4th", month=7, day=4, observance=nearest_workday),
Holiday(
"Juneteenth National Independence Day",
month=6,
day=19,
start_date="2021-06-18",
observance=nearest_workday,
),
Holiday("Independence Day", month=7, day=4, observance=nearest_workday),
USLaborDay,
USColumbusDay,
Holiday("Veterans Day", month=11, day=11, observance=nearest_workday),
USThanksgivingDay,
Holiday("Christmas", month=12, day=25, observance=nearest_workday),
Holiday("Christmas Day", month=12, day=25, observance=nearest_workday),
]


Expand Down