Skip to content

Commit 1c319c4

Browse files
committed
DOC: Validate docstrings for tseries.offsets.BusinessDay
1 parent 7863029 commit 1c319c4

File tree

2 files changed

+73
-16
lines changed

2 files changed

+73
-16
lines changed

ci/code_checks.sh

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,13 +105,9 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
105105
-i "pandas.tseries.offsets.BYearEnd.month GL08" \
106106
-i "pandas.tseries.offsets.BYearEnd.n GL08" \
107107
-i "pandas.tseries.offsets.BYearEnd.normalize GL08" \
108-
-i "pandas.tseries.offsets.BusinessDay PR02,SA01" \
109-
-i "pandas.tseries.offsets.BusinessDay.calendar GL08" \
110-
-i "pandas.tseries.offsets.BusinessDay.holidays GL08" \
111108
-i "pandas.tseries.offsets.BusinessDay.is_on_offset GL08" \
112109
-i "pandas.tseries.offsets.BusinessDay.n GL08" \
113110
-i "pandas.tseries.offsets.BusinessDay.normalize GL08" \
114-
-i "pandas.tseries.offsets.BusinessDay.weekmask GL08" \
115111
-i "pandas.tseries.offsets.BusinessHour PR02,SA01" \
116112
-i "pandas.tseries.offsets.BusinessHour.calendar GL08" \
117113
-i "pandas.tseries.offsets.BusinessHour.end GL08" \

pandas/_libs/tslibs/offsets.pyx

Lines changed: 73 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1776,9 +1776,19 @@ cdef class BusinessMixin(SingleConstructorOffset):
17761776
cdef readonly:
17771777
timedelta _offset
17781778
# Only Custom subclasses use weekmask, holiday, calendar
1779-
object weekmask, holidays, calendar
1779+
object _weekmask, _holidays, _calendar
17801780

17811781
def __init__(self, n=1, normalize=False, offset=timedelta(0)):
1782+
"""
1783+
Parameters
1784+
----------
1785+
n : int, default 1
1786+
The number of days represented.
1787+
normalize : bool, default False
1788+
Normalize start/end dates to midnight.
1789+
offset : timedelta, default timedelta(0)
1790+
Time offset to apply.
1791+
"""
17821792
BaseOffset.__init__(self, n, normalize)
17831793
self._offset = offset
17841794

@@ -1792,9 +1802,9 @@ cdef class BusinessMixin(SingleConstructorOffset):
17921802
# Custom offset instances are identified by the
17931803
# following two attributes. See DateOffset._params()
17941804
# holidays, weekmask
1795-
self.weekmask = weekmask
1796-
self.holidays = holidays
1797-
self.calendar = calendar
1805+
self._weekmask = weekmask
1806+
self._holidays = holidays
1807+
self._calendar = calendar
17981808

17991809
@property
18001810
def offset(self):
@@ -1803,6 +1813,56 @@ cdef class BusinessMixin(SingleConstructorOffset):
18031813
"""
18041814
# Alias for backward compat
18051815
return self._offset
1816+
1817+
@property
1818+
def weekmask(self):
1819+
"""
1820+
Return the weekmask of valid business days.
1821+
1822+
See Also
1823+
--------
1824+
CustomBusinessDay : An offset that can be specified with a weekmask.
1825+
1826+
Examples
1827+
--------
1828+
>>> pd.offsets.CustomBusinessDay(weekmask="Mon Tue Wed").weekmask
1829+
'Mon Tue Wed'
1830+
"""
1831+
return self._weekmask
1832+
1833+
@property
1834+
def holidays(self):
1835+
"""
1836+
Return a list of holidays for this offset.
1837+
1838+
See Also
1839+
--------
1840+
CustomBusinessDay : An offset that can be specified with holidays.
1841+
1842+
Examples
1843+
--------
1844+
>>> pd.offsets.CustomBusinessDay(holidays=["2025-12-25"]).holidays
1845+
(Timestamp('2025-12-25 00:00:00'),)
1846+
"""
1847+
return self._holidays
1848+
1849+
@property
1850+
def calendar(self):
1851+
"""
1852+
Return the calendar object for this offset.
1853+
1854+
See Also
1855+
--------
1856+
numpy.busdaycalendar : The underlying calendar object used.
1857+
CustomBusinessDay : An offset that can be specified with a calendar.
1858+
1859+
Examples
1860+
--------
1861+
>>> cal = np.busdaycalendar(weekmask="Mon Tue Wed")
1862+
>>> pd.offsets.CustomBusinessDay(calendar=cal).calendar
1863+
<numpy.busdaycalendar object at ...>
1864+
"""
1865+
return self._calendar
18061866

18071867
def _repr_attrs(self) -> str:
18081868
if self.offset:
@@ -1840,14 +1900,15 @@ cdef class BusinessDay(BusinessMixin):
18401900
"""
18411901
DateOffset subclass representing possibly n business days.
18421902
1843-
Parameters
1844-
----------
1845-
n : int, default 1
1846-
The number of days represented.
1847-
normalize : bool, default False
1848-
Normalize start/end dates to midnight.
1849-
offset : timedelta, default timedelta(0)
1850-
Time offset to apply.
1903+
This offset increments dates by a given number of business days,
1904+
defined as Monday through Friday. It can be used to move forward or
1905+
backward in time, skipping weekends.
1906+
1907+
See Also
1908+
--------
1909+
DateOffset : Standard kind of date increment.
1910+
CustomBusinessDay : A business day offset that allows for custom
1911+
weekmasks and holidays.
18511912
18521913
Examples
18531914
--------

0 commit comments

Comments
 (0)