From 715ef4be3466db1185f7273982515bc8b6d6a0af Mon Sep 17 00:00:00 2001 From: MomIsBestFriend <> Date: Mon, 23 Mar 2020 18:31:12 +0200 Subject: [PATCH 1/3] DOC: Fixed examples in pandas/tseries --- ci/code_checks.sh | 4 ++++ pandas/tseries/frequencies.py | 10 ++++++---- pandas/tseries/holiday.py | 37 ++++++++++++++++++++++++++--------- 3 files changed, 38 insertions(+), 13 deletions(-) diff --git a/ci/code_checks.sh b/ci/code_checks.sh index 15b4128424eb1..ded965e6049b8 100755 --- a/ci/code_checks.sh +++ b/ci/code_checks.sh @@ -325,6 +325,10 @@ if [[ -z "$CHECK" || "$CHECK" == "doctests" ]]; then MSG='Doctests generic.py' ; echo $MSG pytest -q --doctest-modules pandas/core/generic.py RET=$(($RET + $?)) ; echo $MSG "DONE" + + MSG='Doctests tseries' ; echo $MSG + pytest -q --doctest-modules pandas/tseries/ + RET=$(($RET + $?)) ; echo $MSG "DONE" fi ### DOCSTRINGS ### diff --git a/pandas/tseries/frequencies.py b/pandas/tseries/frequencies.py index 077c5046ac44d..0f2e8991e22ee 100644 --- a/pandas/tseries/frequencies.py +++ b/pandas/tseries/frequencies.py @@ -95,16 +95,18 @@ def to_offset(freq) -> Optional[DateOffset]: Examples -------- - >>> to_offset('5min') + >>> import datetime + + >>> to_offset("5min") <5 * Minutes> - >>> to_offset('1D1H') + >>> to_offset("1D1H") <25 * Hours> - >>> to_offset(('W', 2)) + >>> to_offset(("W", 2)) <2 * Weeks: weekday=6> - >>> to_offset((2, 'B')) + >>> to_offset((2, "B")) <2 * BusinessDays> >>> to_offset(datetime.timedelta(days=1)) diff --git a/pandas/tseries/holiday.py b/pandas/tseries/holiday.py index fe30130e87c01..8ab37f787bd10 100644 --- a/pandas/tseries/holiday.py +++ b/pandas/tseries/holiday.py @@ -157,15 +157,34 @@ class from pandas.tseries.offsets -------- >>> from pandas.tseries.holiday import Holiday, nearest_workday >>> from dateutil.relativedelta import MO - >>> USMemorialDay = Holiday('Memorial Day', month=5, day=31, - offset=pd.DateOffset(weekday=MO(-1))) - >>> USLaborDay = Holiday('Labor Day', month=9, day=1, - offset=pd.DateOffset(weekday=MO(1))) - >>> July3rd = Holiday('July 3rd', month=7, day=3,) - >>> NewYears = Holiday('New Years Day', month=1, day=1, - observance=nearest_workday), - >>> July3rd = Holiday('July 3rd', month=7, day=3, - days_of_week=(0, 1, 2, 3)) + + >>> USMemorialDay = Holiday( + ... "Memorial Day", month=5, day=31, offset=pd.DateOffset(weekday=MO(-1)) + ... ) + >>> USMemorialDay + Holiday: Memorial Day (month=5, day=31, offset=) + + >>> USLaborDay = Holiday( + ... "Labor Day", month=9, day=1, offset=pd.DateOffset(weekday=MO(1)) + ... ) + >>> USLaborDay + Holiday: Labor Day (month=9, day=1, offset=) + + >>> July3rd = Holiday("July 3rd", month=7, day=3) + >>> July3rd + Holiday: July 3rd (month=7, day=3, ) + + >>> NewYears = Holiday( + ... "New Years Day", month=1, day=1, observance=nearest_workday + ... ) + >>> NewYears # doctest: +SKIP + Holiday: New Years Day ( + month=1, day=1, observance= + ) + + >>> July3rd = Holiday("July 3rd", month=7, day=3, days_of_week=(0, 1, 2, 3)) + >>> July3rd + Holiday: July 3rd (month=7, day=3, ) """ if offset is not None and observance is not None: raise NotImplementedError("Cannot use both offset and observance.") From 8cf1d9049863fbee98d635ea9f28e04d9ac194ca Mon Sep 17 00:00:00 2001 From: MomIsBestFriend <> Date: Mon, 23 Mar 2020 18:51:58 +0200 Subject: [PATCH 2/3] Restart Github actions From 95b70f786798dfa252a1571ec564f118be20cea5 Mon Sep 17 00:00:00 2001 From: MomIsBestFriend <> Date: Tue, 24 Mar 2020 01:37:33 +0200 Subject: [PATCH 3/3] Using pd.Timedelta --- pandas/tseries/frequencies.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/pandas/tseries/frequencies.py b/pandas/tseries/frequencies.py index 0f2e8991e22ee..22c0f455fa3ac 100644 --- a/pandas/tseries/frequencies.py +++ b/pandas/tseries/frequencies.py @@ -95,8 +95,6 @@ def to_offset(freq) -> Optional[DateOffset]: Examples -------- - >>> import datetime - >>> to_offset("5min") <5 * Minutes> @@ -109,7 +107,7 @@ def to_offset(freq) -> Optional[DateOffset]: >>> to_offset((2, "B")) <2 * BusinessDays> - >>> to_offset(datetime.timedelta(days=1)) + >>> to_offset(pd.Timedelta(days=1)) >>> to_offset(Hour())