Skip to content

Commit 9921168

Browse files
BklynChuliangXiaojreback
authored
Holiday rename; Juneteenth start_date (#44576)
* add Juneteenth to USFederalHolidayCalendar * Standardize federal holiday names Reference https://www.opm.gov/policy-data-oversight/pay-leave/federal-holidays/#url=2021 * short long code line * ENH: Holidays: add Juneteenth start_date (#42328, #44574) Co-authored-by: Chuliang Xiao <[email protected]> Co-authored-by: Jeff Reback <[email protected]>
1 parent 124bee2 commit 9921168

File tree

4 files changed

+42
-17
lines changed

4 files changed

+42
-17
lines changed

doc/source/whatsnew/v1.4.0.rst

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,8 @@ Other enhancements
214214
- :meth:`Timestamp.isoformat`, now handles the ``timespec`` argument from the base :class:``datetime`` class (:issue:`26131`)
215215
- :meth:`NaT.to_numpy` ``dtype`` argument is now respected, so ``np.timedelta64`` can be returned (:issue:`44460`)
216216
- New option ``display.max_dir_items`` customizes the number of columns added to :meth:`Dataframe.__dir__` and suggested for tab completion (:issue:`37996`)
217+
- Added "Juneteenth National Independence Day" to
218+
``USFederalHolidayCalendar``. See also `Other API changes`_.
217219
- :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`)
218220

219221

@@ -437,6 +439,18 @@ Other API changes
437439
- :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`)
438440
- Change in the position of the ``min_rows`` argument in :meth:`DataFrame.to_string` due to change in the docstring (:issue:`44304`)
439441
- Reduction operations for :class:`DataFrame` or :class:`Series` now raising a ``ValueError`` when ``None`` is passed for ``skipna`` (:issue:`44178`)
442+
- Changed the ``name`` attribute of several holidays in
443+
``USFederalHolidayCalendar`` to match `official federal holiday
444+
names <https://www.opm.gov/policy-data-oversight/pay-leave/federal-holidays/>`_
445+
specifically:
446+
447+
- "New Year's Day" gains the possessive apostrophe
448+
- "Presidents Day" becomes "Washington's Birthday"
449+
- "Martin Luther King Jr. Day" is now "Birthday of Martin Luther King, Jr."
450+
- "July 4th" is now "Independence Day"
451+
- "Thanksgiving" is now "Thanksgiving Day"
452+
- "Christmas" is now "Christmas Day"
453+
- Added "Juneteenth National Independence Day"
440454
-
441455

442456
.. ---------------------------------------------------------------------------

pandas/tests/tseries/holiday/test_calendar.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def test_calendar_observance_dates():
8585

8686
def test_rule_from_name():
8787
us_fed_cal = get_calendar("USFederalHolidayCalendar")
88-
assert us_fed_cal.rule_from_name("Thanksgiving") == USThanksgivingDay
88+
assert us_fed_cal.rule_from_name("Thanksgiving Day") == USThanksgivingDay
8989

9090

9191
def test_calendar_2031():

pandas/tests/tseries/holiday/test_holiday.py

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -164,19 +164,23 @@ def test_holiday_dates(holiday, start_date, end_date, expected):
164164
(EasterMonday, "2015-04-06", "2015-04-06"),
165165
(EasterMonday, datetime(2015, 7, 1), []),
166166
(EasterMonday, "2015-04-05", []),
167-
("New Years Day", "2015-01-01", "2015-01-01"),
168-
("New Years Day", "2010-12-31", "2010-12-31"),
169-
("New Years Day", datetime(2015, 7, 1), []),
170-
("New Years Day", "2011-01-01", []),
171-
("July 4th", "2015-07-03", "2015-07-03"),
172-
("July 4th", datetime(2015, 7, 1), []),
173-
("July 4th", "2015-07-04", []),
167+
("New Year's Day", "2015-01-01", "2015-01-01"),
168+
("New Year's Day", "2010-12-31", "2010-12-31"),
169+
("New Year's Day", datetime(2015, 7, 1), []),
170+
("New Year's Day", "2011-01-01", []),
171+
("Independence Day", "2015-07-03", "2015-07-03"),
172+
("Independence Day", datetime(2015, 7, 1), []),
173+
("Independence Day", "2015-07-04", []),
174174
("Veterans Day", "2012-11-12", "2012-11-12"),
175175
("Veterans Day", datetime(2015, 7, 1), []),
176176
("Veterans Day", "2012-11-11", []),
177-
("Christmas", "2011-12-26", "2011-12-26"),
178-
("Christmas", datetime(2015, 7, 1), []),
179-
("Christmas", "2011-12-25", []),
177+
("Christmas Day", "2011-12-26", "2011-12-26"),
178+
("Christmas Day", datetime(2015, 7, 1), []),
179+
("Christmas Day", "2011-12-25", []),
180+
("Juneteenth National Independence Day", "2020-06-19", []),
181+
("Juneteenth National Independence Day", "2021-06-18", "2021-06-18"),
182+
("Juneteenth National Independence Day", "2022-06-19", []),
183+
("Juneteenth National Independence Day", "2022-06-20", "2022-06-20"),
180184
],
181185
)
182186
def test_holidays_within_dates(holiday, start, expected):

pandas/tseries/holiday.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -531,17 +531,17 @@ def merge(self, other, inplace=False):
531531
"Columbus Day", month=10, day=1, offset=DateOffset(weekday=MO(2))
532532
)
533533
USThanksgivingDay = Holiday(
534-
"Thanksgiving", month=11, day=1, offset=DateOffset(weekday=TH(4))
534+
"Thanksgiving Day", month=11, day=1, offset=DateOffset(weekday=TH(4))
535535
)
536536
USMartinLutherKingJr = Holiday(
537-
"Martin Luther King Jr. Day",
537+
"Birthday of Martin Luther King, Jr.",
538538
start_date=datetime(1986, 1, 1),
539539
month=1,
540540
day=1,
541541
offset=DateOffset(weekday=MO(3)),
542542
)
543543
USPresidentsDay = Holiday(
544-
"Presidents Day", month=2, day=1, offset=DateOffset(weekday=MO(3))
544+
"Washington’s Birthday", month=2, day=1, offset=DateOffset(weekday=MO(3))
545545
)
546546
GoodFriday = Holiday("Good Friday", month=1, day=1, offset=[Easter(), Day(-2)])
547547

@@ -556,16 +556,23 @@ class USFederalHolidayCalendar(AbstractHolidayCalendar):
556556
"""
557557

558558
rules = [
559-
Holiday("New Years Day", month=1, day=1, observance=nearest_workday),
559+
Holiday("New Year's Day", month=1, day=1, observance=nearest_workday),
560560
USMartinLutherKingJr,
561561
USPresidentsDay,
562562
USMemorialDay,
563-
Holiday("July 4th", month=7, day=4, observance=nearest_workday),
563+
Holiday(
564+
"Juneteenth National Independence Day",
565+
month=6,
566+
day=19,
567+
start_date="2021-06-18",
568+
observance=nearest_workday,
569+
),
570+
Holiday("Independence Day", month=7, day=4, observance=nearest_workday),
564571
USLaborDay,
565572
USColumbusDay,
566573
Holiday("Veterans Day", month=11, day=11, observance=nearest_workday),
567574
USThanksgivingDay,
568-
Holiday("Christmas", month=12, day=25, observance=nearest_workday),
575+
Holiday("Christmas Day", month=12, day=25, observance=nearest_workday),
569576
]
570577

571578

0 commit comments

Comments
 (0)