At present, it is not possible to determine both the bias and compliance parameters in the same vacation rule.
I found this problem with boxing day in England . Boxing Day is the next business day after Christmas.
I encoded the solution using a compliance parameter that points to the corresponding rule, in this case: after_nearest_workday
Holiday('Christmas', month=12, day=25, observance=nearest_workday), Holiday('Boxing Day', month=12, day=25, observance=after_nearest_workday)
after_nearest_workday is a function. If you need a different compliance rule, you can create your own function, for example, the following original Pandas watch functions:
def nearest_workday(dt): """ If holiday falls on Saturday, use day before (Friday) instead; if holiday falls on Sunday, use day thereafter (Monday) instead. """ if dt.weekday() == 5: return dt - timedelta(1) elif dt.weekday() == 6: return dt + timedelta(1) return dt def after_nearest_workday(dt): """ returns next workday after nearest workday needed for Boxing day or multiple holidays in a series """ return next_workday(nearest_workday(dt))
source share