Adding Holidays To Usfederalholidaycalendar()
Solution 1:
You can use pandas.tseries.holiday.HolidayCalendarFactory
to compose multiple calendar rule sets. One example is here: https://stackoverflow.com/a/33096916/4323 and the (sparse) docs are here: https://pandas.pydata.org/pandas-docs/stable/timeseries.html
Having said all that, if you only need the calendar for a couple of years you are better off making it explicitly with a list of holidays and NumPy's busdaycalendar
. This is a more efficient, vectorized API (you could also create the NumPy calendar from the Pandas one if you do need a lot of years or complex rules). The problem with the Pandas business day stuff is that applying offsets using it is not vectorized, and is therefore slow (it even generates a warning when you use it). Also, some countries have holidays which cannot be represented by rules. So, consider just "hard coding" your holidays if you don't have very many, or load them from some other source (e.g. a one-time web scrape into a text file).
Post a Comment for "Adding Holidays To Usfederalholidaycalendar()"