Skip to content

DOC: Validate docstrings for tseries.offsets.BusinessDay #62078

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions ci/code_checks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,9 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
-i "pandas.tseries.offsets.BYearEnd.month GL08" \
-i "pandas.tseries.offsets.BYearEnd.n GL08" \
-i "pandas.tseries.offsets.BYearEnd.normalize GL08" \
-i "pandas.tseries.offsets.BusinessDay PR02,SA01" \
-i "pandas.tseries.offsets.BusinessDay.calendar GL08" \
-i "pandas.tseries.offsets.BusinessDay.holidays GL08" \
-i "pandas.tseries.offsets.BusinessDay.is_on_offset GL08" \
-i "pandas.tseries.offsets.BusinessDay.n GL08" \
-i "pandas.tseries.offsets.BusinessDay.normalize GL08" \
-i "pandas.tseries.offsets.BusinessDay.weekmask GL08" \
-i "pandas.tseries.offsets.BusinessHour PR02,SA01" \
-i "pandas.tseries.offsets.BusinessHour.calendar GL08" \
-i "pandas.tseries.offsets.BusinessHour.end GL08" \
Expand Down
85 changes: 73 additions & 12 deletions pandas/_libs/tslibs/offsets.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1776,9 +1776,19 @@ cdef class BusinessMixin(SingleConstructorOffset):
cdef readonly:
timedelta _offset
# Only Custom subclasses use weekmask, holiday, calendar
object weekmask, holidays, calendar
object _weekmask, _holidays, _calendar

def __init__(self, n=1, normalize=False, offset=timedelta(0)):
"""
Parameters
----------
n : int, default 1
The number of days represented.
normalize : bool, default False
Normalize start/end dates to midnight.
offset : timedelta, default timedelta(0)
Time offset to apply.
"""
BaseOffset.__init__(self, n, normalize)
self._offset = offset

Expand All @@ -1792,9 +1802,9 @@ cdef class BusinessMixin(SingleConstructorOffset):
# Custom offset instances are identified by the
# following two attributes. See DateOffset._params()
# holidays, weekmask
self.weekmask = weekmask
self.holidays = holidays
self.calendar = calendar
self._weekmask = weekmask
self._holidays = holidays
self._calendar = calendar

@property
def offset(self):
Expand All @@ -1803,6 +1813,56 @@ cdef class BusinessMixin(SingleConstructorOffset):
"""
# Alias for backward compat
return self._offset

@property
def weekmask(self):
"""
Return the weekmask of valid business days.

See Also
--------
CustomBusinessDay : An offset that can be specified with a weekmask.

Examples
--------
>>> pd.offsets.CustomBusinessDay(weekmask="Mon Tue Wed").weekmask
'Mon Tue Wed'
"""
return self._weekmask

@property
def holidays(self):
"""
Return a list of holidays for this offset.

See Also
--------
CustomBusinessDay : An offset that can be specified with holidays.

Examples
--------
>>> pd.offsets.CustomBusinessDay(holidays=["2025-12-25"]).holidays
(Timestamp('2025-12-25 00:00:00'),)
"""
return self._holidays

@property
def calendar(self):
"""
Return the calendar object for this offset.

See Also
--------
numpy.busdaycalendar : The underlying calendar object used.
CustomBusinessDay : An offset that can be specified with a calendar.

Examples
--------
>>> cal = np.busdaycalendar(weekmask="Mon Tue Wed")
>>> pd.offsets.CustomBusinessDay(calendar=cal).calendar
<numpy.busdaycalendar object at ...>
"""
return self._calendar

def _repr_attrs(self) -> str:
if self.offset:
Expand Down Expand Up @@ -1840,14 +1900,15 @@ cdef class BusinessDay(BusinessMixin):
"""
DateOffset subclass representing possibly n business days.

Parameters
----------
n : int, default 1
The number of days represented.
normalize : bool, default False
Normalize start/end dates to midnight.
offset : timedelta, default timedelta(0)
Time offset to apply.
This offset increments dates by a given number of business days,
defined as Monday through Friday. It can be used to move forward or
backward in time, skipping weekends.

See Also
--------
DateOffset : Standard kind of date increment.
CustomBusinessDay : A business day offset that allows for custom
weekmasks and holidays.

Examples
--------
Expand Down
Loading