Functions to handle business days calculations
Maintained. Last release 3 weeks ago, commits in 3 of the last 26 weeks. Weaker on commit activity and contributor spread.
pip install bizdayspython-bizdays
bizdays computes business days with holiday calendars. This README covers
bizdays 2.0, which runs on Python 3.10 to 3.14 with NumPy 1.24 or newer and
pandas 2 or 3. bizdays.Calendar accepts single dates, Python sequences,
NumPy arrays and pandas date-like inputs, and returns NumPy scalars or arrays.
Install
pip install bizdays
Install the optional integrations with:
pip install "bizdays[pmc]"
pip install "bizdays[xcal]"
pip install "bizdays[work]"
Quickstart
>>> from bizdays import Calendar
>>> cal = Calendar.load(name="ANBIMA")
>>> cal.bizdays("2014-01-13", "2015-01-13")
np.float64(253.0)
>>> cal.following("2015-12-25")
np.datetime64('2015-12-28')
>>> cal.offset(["2014-01-02", "2014-01-03"], [1, 5])
array(['2014-01-03', '2014-01-10'], dtype='datetime64[D]')
>>> cal.seq("2014-01-02", "2014-01-07")
array(['2014-01-02', '2014-01-03', '2014-01-06', '2014-01-07'],
dtype='datetime64[D]')
>>> cal.getdate("15th day", "2002-05")
np.datetime64('2002-05-15')
>>> cal.getbizdays(2024)
np.float64(253.0)
Calendars that come with the package
ANBIMA: 2000-01-01 to 2099-12-25. Official ANBIMA holidays up to 2079; later years are projected with the national holiday rule.B3: official B3 holidays for 2000-2026. Years 2027-2099 are projected: ANBIMA holidays, plus December 24, plus the last weekday of the year. Projected years are replaced when B3 publishes them.Actual: no holidays, every day is a business day; 1900-01-01 to 2199-12-31.
You can list them with list_calendars():
>>> from bizdays import list_calendars
>>> list_calendars()["packaged"]
['ANBIMA', 'B3', 'Actual']
Use Calendar.load(name="...") for packaged calendars and
Calendar.load(filename="...") for custom JSON calendar files.