ENH: Juneteenth holiday · Issue #44574 · pandas-dev/pandas (original) (raw)

No

Describe the solution you'd like

The USFederalHolidayCalendar should add Juneteenth. The holiday was first declared and observed on 2021-06-18, but financial markets were not closed on that day. They will be starting in 2022.

API breaking implications

Users of the USFederalHolidayCalendar will observe a new holiday which should fall on the nearest_workday to 19-June.

Describe alternatives you've considered

A user can add this holiday rule manually to the current USFederalHolidayCalendar, but it makes sense to include it going forward.

Additional context

https://www.whitehouse.gov/briefing-room/presidential-actions/2021/06/18/a-proclamation-on-juneteenth-day-of-observance-2021/
https://www.nyse.com/markets/hours-calendars

#!/usr/bin/env python3

import itertools from pandas.tseries.holiday import get_calendar, nearest_workday, Holiday

usfh = get_calendar("USFederalHolidayCalendar") juneteenth = Holiday( "Juneteenth", month=6, day=19, start_date="2022-06-20", observance=nearest_workday ) if not any(h.name == "Juneteenth" for h in usfh.rules): usfh.rules.append(juneteenth)

for year, dates in itertools.groupby( usfh.holidays("2021-01-01", "2030-12-31"), key=lambda x: x.year ): print(f"{year}: {' '.join(d.strftime('%d-%b') for d in dates)}")

Output:

2021: 01-Jan 18-Jan 15-Feb 31-May 05-Jul 06-Sep 11-Oct 11-Nov 25-Nov 24-Dec 31-Dec
2022: 17-Jan 21-Feb 30-May 20-Jun 04-Jul 05-Sep 10-Oct 11-Nov 24-Nov 26-Dec
2023: 02-Jan 16-Jan 20-Feb 29-May 19-Jun 04-Jul 04-Sep 09-Oct 10-Nov 23-Nov 25-Dec
2024: 01-Jan 15-Jan 19-Feb 27-May 19-Jun 04-Jul 02-Sep 14-Oct 11-Nov 28-Nov 25-Dec
2025: 01-Jan 20-Jan 17-Feb 26-May 19-Jun 04-Jul 01-Sep 13-Oct 11-Nov 27-Nov 25-Dec
2026: 01-Jan 19-Jan 16-Feb 25-May 19-Jun 03-Jul 07-Sep 12-Oct 11-Nov 26-Nov 25-Dec
2027: 01-Jan 18-Jan 15-Feb 31-May 18-Jun 05-Jul 06-Sep 11-Oct 11-Nov 25-Nov 24-Dec 31-Dec
2028: 17-Jan 21-Feb 29-May 19-Jun 04-Jul 04-Sep 09-Oct 10-Nov 23-Nov 25-Dec
2029: 01-Jan 15-Jan 19-Feb 28-May 19-Jun 04-Jul 03-Sep 08-Oct 12-Nov 22-Nov 25-Dec
2030: 01-Jan 21-Jan 18-Feb 27-May 19-Jun 04-Jul 02-Sep 14-Oct 11-Nov 28-Nov 25-Dec