numpy.busdaycalendar

class numpy.busdaycalendar

A business day calendar object that efficiently stores information defining business days for the business day-related functions.

New in version 1.7.0.

Parameters :

weekmask : str or array_like of bool, optional

A seven-element array indicating which of Monday through Sunday may be valid business days. May be specified as a list or array, like [1,1,1,1,1,0,0], a length-seven string like ‘1111100’, or a string of three-letter weekday names, like ‘MonTueWedThuFri’. The latter string representation is most useful when only one day of the week is important, like ‘Mon’ if you want to calculate the date of Easter.

holidays : array_like of datetime64[D], optional

An array of dates which should be blacked out from being considered as business days. They may be specified in any order, and NaT (not-a-time) dates are ignored. Internally, this list is normalized into a form suited for fast business day calculations.

Returns :

out : busdaycalendar

A business day calendar object containing the specified weekmask and holidays.

See also

is_busday
Returns a boolean array indicating valid business days.
busday_offset
Applies an offset counted in business days.
busday_count
Counts how many business days are in a half-open date range.

Examples

>>> # Some important days in July
... bdd = np.busdaycalendar(
...             holidays=['2011-07-01', '2011-07-04', '2011-07-17'])
>>> # Default is Monday to Friday weekdays
... bdd.weekmask
array([ True,  True,  True,  True,  True, False, False], dtype='bool')
>>> # Any holidays already on the weekend are removed
... bdd.holidays
array(['2011-07-01', '2011-07-04'], dtype='datetime64[D]')

Attributes

weekmask
holidays

Previous topic

numpy.busday_count

This Page