pandas.bdate_range#

pandas.bdate_range(start=None,end=None,periods=None,freq='B',tz=None,normalize=True,name=None,weekmask=None,holidays=None,inclusive='both',**kwargs)[source]#

Return a fixed frequency DatetimeIndex with business day as the default.

Parameters:
startstr or datetime-like, default None

Left bound for generating dates.

endstr or datetime-like, default None

Right bound for generating dates.

periodsint, default None

Number of periods to generate.

freqstr, Timedelta, datetime.timedelta, or DateOffset, default ‘B’

Frequency strings can have multiples, e.g. ‘5h’. The default isbusiness daily (‘B’).

tzstr or None

Time zone name for returning localized DatetimeIndex, for exampleAsia/Beijing.

normalizebool, default False

Normalize start/end dates to midnight before generating date range.

nameHashable, default None

Name of the resulting DatetimeIndex.

weekmaskstr or None, default None

Weekmask of valid business days, passed tonumpy.busdaycalendar,only used when custom frequency strings are passed. The defaultvalue None is equivalent to ‘Mon Tue Wed Thu Fri’.

holidayslist-like or None, default None

Dates to exclude from the set of valid business days, passed tonumpy.busdaycalendar, only used when custom frequency stringsare passed.

inclusive{“both”, “neither”, “left”, “right”}, default “both”

Include boundaries; Whether to set each bound as closed or open.

**kwargs

For compatibility. Has no effect on the result.

Returns:
DatetimeIndex

Fixed frequency DatetimeIndex.

See also

date_range

Return a fixed frequency DatetimeIndex.

period_range

Return a fixed frequency PeriodIndex.

timedelta_range

Return a fixed frequency TimedeltaIndex.

Notes

Of the four parameters:start,end,periods, andfreq,exactly three must be specified. Specifyingfreq is a requirementforbdate_range. Usedate_range if specifyingfreq is notdesired.

To learn more about the frequency strings, please seethis link.

Examples

Note how the two weekend days are skipped in the result.

>>>pd.bdate_range(start="1/1/2018",end="1/08/2018")DatetimeIndex(['2018-01-01', '2018-01-02', '2018-01-03', '2018-01-04',           '2018-01-05', '2018-01-08'],          dtype='datetime64[us]', freq='B')