NumPy | busdaycalendar object
Start your free 7-days trial now!
Numpy's busdaycalendar
object encodes user-provided dates that are considered to be valid. Note that busday stands for business day, but we can specify what a "business" day is via the parameters.
Once a busdaycalendar object is made, it cannot be mutated.
Parameters
1. weekmask
| string
or array-like
of boolean
| optional
The days of the week that are considered to be valid. You could either specify a string of length 7 with 0s representing invalid and 1s representing valid weekdays, from Monday to Sunday. For instance, "1111100"
would mean that weekends (Saturday and Sunday) would be invalid dates. Also, instead of typing in binaries, you could also use three-character abbreviations like:
Mon Tue Wed Thu Fri Sat Sun
For instance, "Mon Wed Fri"
would mean that only Mondays, Wednesdays and Fridays are valid dates, and all other weekdays are invalid.
Alternatively, you could provide an array of booleans of size 7, where True means that that corresponding weekday is valid, and False otherwise. For instance, [True,True,True,True,True,False,False]
would again mean that weekends would be invalid dates.
By default, weekmask="1111100"
, that is, valid weekdays are from Monday to Friday (both inclusive).
2. holidays
| array-like
of datetime
| optional
An array of datetimes that are deemed as invalid dates. Datetimes are essentially strings formatted like so:
"2020-05-25"
Return value
A busdaycalendar
object that encodes the provided parameters.
Examples
Basic usage
np.busdaycalendar("1111110", ["2020-12-25", "2020-12-26", "2020-12-27"])
array([ True, True, False])
Here, we're setting three dates as invalidate dates, and we're also setting all dates that fall on Sunday as invalid dates.