QuickstartΒΆ
This page shows bizdays 2.0. A single bizdays.Calendar instance works with scalar inputs, vectorized inputs, NumPy arrays, and pandas date-like values.
[1]:
from bizdays import Calendar
cal = Calendar.load(name="ANBIMA")
cal
[1]:
Calendar: ANBIMA
Start: 2000-01-01
End: 2099-12-25
Weekdays: Saturday, Sunday
Holidays: 1275
Financial: True
Business-day counts are available through bizdays.
[2]:
cal.bizdays("2014-01-13", "2015-01-13")
[2]:
np.float64(253.0)
Date adjustment methods return NumPy dates.
[3]:
cal.following("2015-12-25")
[3]:
np.datetime64('2015-12-28')
Vectorized methods return NumPy arrays.
[4]:
cal.offset(["2014-01-02", "2014-01-03"], [1, 5])
[4]:
array(['2014-01-03', '2014-01-10'], dtype='datetime64[D]')
[5]:
cal.seq("2014-01-02", "2014-01-07")
[5]:
array(['2014-01-02', '2014-01-03', '2014-01-06', '2014-01-07'],
dtype='datetime64[D]')
getdate resolves date expressions against month, year, or date references.
[6]:
cal.getdate("15th day", "2002-05")
[6]:
np.datetime64('2002-05-15')
getbizdays counts the business days in a whole year, or in one month.
[7]:
cal.getbizdays(2024)
[7]:
np.float64(253.0)
Missing values give missing results. A vector of flags is a masked array: a NumPy array with a mask that marks the missing elements (shown as --).
[8]:
cal.isbizday(["2024-01-01", None, "2024-01-02"])
[8]:
masked_array(data=[False, --, True],
mask=[False, True, False],
fill_value=False)
Next: the API reference lists every method with examples, and the migration guide covers code written for bizdays 1.x.