Skip to content

Commit 13b9e40

Browse files
authored
DOC: Fixed examples in pandas/tseries (#32935)
1 parent b6cb1a4 commit 13b9e40

File tree

3 files changed

+37
-14
lines changed

3 files changed

+37
-14
lines changed

ci/code_checks.sh

+4
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,10 @@ if [[ -z "$CHECK" || "$CHECK" == "doctests" ]]; then
325325
MSG='Doctests generic.py' ; echo $MSG
326326
pytest -q --doctest-modules pandas/core/generic.py
327327
RET=$(($RET + $?)) ; echo $MSG "DONE"
328+
329+
MSG='Doctests tseries' ; echo $MSG
330+
pytest -q --doctest-modules pandas/tseries/
331+
RET=$(($RET + $?)) ; echo $MSG "DONE"
328332
fi
329333

330334
### DOCSTRINGS ###

pandas/tseries/frequencies.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -95,19 +95,19 @@ def to_offset(freq) -> Optional[DateOffset]:
9595
9696
Examples
9797
--------
98-
>>> to_offset('5min')
98+
>>> to_offset("5min")
9999
<5 * Minutes>
100100
101-
>>> to_offset('1D1H')
101+
>>> to_offset("1D1H")
102102
<25 * Hours>
103103
104-
>>> to_offset(('W', 2))
104+
>>> to_offset(("W", 2))
105105
<2 * Weeks: weekday=6>
106106
107-
>>> to_offset((2, 'B'))
107+
>>> to_offset((2, "B"))
108108
<2 * BusinessDays>
109109
110-
>>> to_offset(datetime.timedelta(days=1))
110+
>>> to_offset(pd.Timedelta(days=1))
111111
<Day>
112112
113113
>>> to_offset(Hour())

pandas/tseries/holiday.py

+28-9
Original file line numberDiff line numberDiff line change
@@ -157,15 +157,34 @@ class from pandas.tseries.offsets
157157
--------
158158
>>> from pandas.tseries.holiday import Holiday, nearest_workday
159159
>>> from dateutil.relativedelta import MO
160-
>>> USMemorialDay = Holiday('Memorial Day', month=5, day=31,
161-
offset=pd.DateOffset(weekday=MO(-1)))
162-
>>> USLaborDay = Holiday('Labor Day', month=9, day=1,
163-
offset=pd.DateOffset(weekday=MO(1)))
164-
>>> July3rd = Holiday('July 3rd', month=7, day=3,)
165-
>>> NewYears = Holiday('New Years Day', month=1, day=1,
166-
observance=nearest_workday),
167-
>>> July3rd = Holiday('July 3rd', month=7, day=3,
168-
days_of_week=(0, 1, 2, 3))
160+
161+
>>> USMemorialDay = Holiday(
162+
... "Memorial Day", month=5, day=31, offset=pd.DateOffset(weekday=MO(-1))
163+
... )
164+
>>> USMemorialDay
165+
Holiday: Memorial Day (month=5, day=31, offset=<DateOffset: weekday=MO(-1)>)
166+
167+
>>> USLaborDay = Holiday(
168+
... "Labor Day", month=9, day=1, offset=pd.DateOffset(weekday=MO(1))
169+
... )
170+
>>> USLaborDay
171+
Holiday: Labor Day (month=9, day=1, offset=<DateOffset: weekday=MO(+1)>)
172+
173+
>>> July3rd = Holiday("July 3rd", month=7, day=3)
174+
>>> July3rd
175+
Holiday: July 3rd (month=7, day=3, )
176+
177+
>>> NewYears = Holiday(
178+
... "New Years Day", month=1, day=1, observance=nearest_workday
179+
... )
180+
>>> NewYears # doctest: +SKIP
181+
Holiday: New Years Day (
182+
month=1, day=1, observance=<function nearest_workday at 0x66545e9bc440>
183+
)
184+
185+
>>> July3rd = Holiday("July 3rd", month=7, day=3, days_of_week=(0, 1, 2, 3))
186+
>>> July3rd
187+
Holiday: July 3rd (month=7, day=3, )
169188
"""
170189
if offset is not None and observance is not None:
171190
raise NotImplementedError("Cannot use both offset and observance.")

0 commit comments

Comments
 (0)