From 4e847ef337948f6e139d6fe4c099ec74126c3764 Mon Sep 17 00:00:00 2001 From: abonte <6319051+abonte@users.noreply.github.com> Date: Wed, 8 Feb 2023 09:24:13 +0100 Subject: [PATCH 1/2] DOC: add/fix Timedeltas docstrings --- pandas/_libs/tslibs/timedeltas.pyx | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/pandas/_libs/tslibs/timedeltas.pyx b/pandas/_libs/tslibs/timedeltas.pyx index d7352f80132a2..9a00adf2d4de7 100644 --- a/pandas/_libs/tslibs/timedeltas.pyx +++ b/pandas/_libs/tslibs/timedeltas.pyx @@ -1025,6 +1025,23 @@ cdef class _Timedelta(timedelta): @property def days(self) -> int: # TODO(cython3): make cdef property + """ + Returns the days of the timedelta. + + Returns + ------- + int + + Examples + -------- + >>> td = pd.Timedelta(1, "d") + >>> td.days + 1 + + >>> td = pd.Timedelta('4 min 3 us 42 ns') + >>> td.days + 0 + """ # NB: using the python C-API PyDateTime_DELTA_GET_DAYS will fail # (or be incorrect) self._ensure_components() @@ -1051,11 +1068,13 @@ cdef class _Timedelta(timedelta): Examples -------- **Using string input** + >>> td = pd.Timedelta('1 days 2 min 3 us 42 ns') >>> td.seconds 120 **Using integer input** + >>> td = pd.Timedelta(42, unit='s') >>> td.seconds 42 @@ -1273,6 +1292,13 @@ cdef class _Timedelta(timedelta): def components(self): """ Return a components namedtuple-like. + + Examples + -------- + >>> td = pd.Timedelta('2 day 4 min 3 us 42 ns') + >>> td.components + Components(days=2, hours=0, minutes=4, seconds=0, milliseconds=0, + microseconds=3, nanoseconds=42) """ self._ensure_components() # return the named tuple From d35382fb66340f7111f9b7dd4efdf61a3a675d07 Mon Sep 17 00:00:00 2001 From: abonte <6319051+abonte@users.noreply.github.com> Date: Wed, 8 Feb 2023 20:59:29 +0100 Subject: [PATCH 2/2] remove function from code_checks.sh --- ci/code_checks.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/ci/code_checks.sh b/ci/code_checks.sh index 3ab63b9bcb860..28ae8ae9d06bc 100755 --- a/ci/code_checks.sh +++ b/ci/code_checks.sh @@ -204,7 +204,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then pandas.Timestamp.utctimetuple \ pandas.Timestamp.weekday \ pandas.arrays.DatetimeArray \ - pandas.Timedelta.components \ pandas.Timedelta.view \ pandas.Timedelta.as_unit \ pandas.Timedelta.ceil \