DateOffset subclass representing custom business month(s).
Increments between beginning of month dates.
The number of months represented.
Normalize start dates to midnight before generating date range.
Weekmask of valid business days, passed to numpy.busdaycalendar.
List/array of dates to exclude from the set of valid business days, passed to numpy.busdaycalendar.
Calendar to integrate.
Time offset to apply.
See also
DateOffsetStandard kind of date increment.
Examples
In the example below we use the default parameters.
>>> ts = pd.Timestamp(2022, 8, 5)
>>> ts + pd.offsets.CustomBusinessMonthBegin()
Timestamp('2022-09-01 00:00:00')
Custom business month start can be specified by weekmask parameter. To convert the returned datetime object to its string representation the function strftime() is used in the next example.
>>> import datetime as dt
>>> freq = pd.offsets.CustomBusinessMonthBegin(weekmask="Wed Thu")
>>> pd.date_range(dt.datetime(2022, 7, 10), dt.datetime(2022, 12, 18),
... freq=freq).strftime('%a %d %b %Y %H:%M')
Index(['Wed 03 Aug 2022 00:00', 'Thu 01 Sep 2022 00:00',
'Wed 05 Oct 2022 00:00', 'Wed 02 Nov 2022 00:00',
'Thu 01 Dec 2022 00:00'],
dtype='object')
Using NumPy business day calendar you can define custom holidays.
>>> import datetime as dt
>>> bdc = np.busdaycalendar(holidays=['2022-08-01', '2022-09-30',
... '2022-10-31', '2022-11-01'])
>>> freq = pd.offsets.CustomBusinessMonthBegin(calendar=bdc)
>>> pd.date_range(dt.datetime(2022, 7, 10), dt.datetime(2022, 11, 10), freq=freq)
DatetimeIndex(['2022-08-02', '2022-09-01', '2022-10-03', '2022-11-02'],
dtype='datetime64[ns]', freq='CBMS')
Attributes
| Returns a copy of the calling offset object with n=1 and all other attributes equal. |
| Define default roll function to be called in apply method. |
Return a string representing the frequency. | |
Return a dict of extra parameters for the offset. | |
| Define default roll function to be called in apply method. |
Return a string representing the base frequency. | |
| Alias for self._offset. |
Methods
| Return a copy of the frequency. |
(DEPRECATED) Return boolean whether the frequency is a unit frequency (n=1). | |
| Return boolean whether a timestamp occurs on the month end. |
| Return boolean whether a timestamp occurs on the month start. |
| Return boolean whether a timestamp intersects with this frequency. |
| Return boolean whether a timestamp occurs on the quarter end. |
| Return boolean whether a timestamp occurs on the quarter start. |
| Return boolean whether a timestamp occurs on the year end. |
| Return boolean whether a timestamp occurs on the year start. |
| Roll provided date backward to next offset only if not on offset. |
| Roll provided date forward to next offset only if not on offset. |
© 2008–2011, AQR Capital Management, LLC, Lambda Foundry, Inc. and PyData Development Team
© 2011–2025, Open source contributors
Licensed under the 3-clause BSD License.
https://pandas.pydata.org/pandas-docs/version/2.3.0/reference/api/pandas.tseries.offsets.CustomBusinessMonthBegin.html