I'm attempting to compute the 5th working day into the future, based on a slightly customized calendar. However, the values for Labor Day (a US holiday in Sept) are computing incorrectly, while the values for the months of January and July (the other months potentially impacted by a holiday) are computed correctly.
I have already tried using
dts + 5 * custom_bday - but that simply moves the problem from Sept values being incorrect, to having January and July values off by a day.
import pandas as pd from datetime import datetime start = datetime(2019,1,1) end = datetime(2024,8,1) dtrange = pd.date_range(start, end, freq='MS') dts = pd.Series(dtrange) hols = holidays.UnitedStates(state='MD', years=[2019,2020,2021,2022,2023,2024]) notholidays = ['American Indian Heritage Day', 'Columbus Day', 'Veterans Day'] realhols = [i for i in sorted(hols.items()) if i not in notholidays] realholsdt = [i for i in realhols] custom_bday = pd.offsets.CustomBusinessDay(holidays=realholsdt) dts + 4 * custom_bday
The expected results are a Series of the 5th workdays of each month, excluding weekends and holidays. However all Labor Day holidays (in Sept) are off, for example
Seeing: 8 2019-09-06
Expecting: 8 2019-09-09