From a7fb6915763ed432800e2d200067c8132e20e622 Mon Sep 17 00:00:00 2001 From: amanlai Date: Wed, 4 Sep 2024 18:22:42 -0700 Subject: [PATCH 1/3] fix some docstring errors --- ci/code_checks.sh | 3 --- pandas/_libs/tslibs/timedeltas.pyx | 13 ++++++++++--- pandas/core/arrays/timedeltas.py | 12 ++++++++++++ 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/ci/code_checks.sh b/ci/code_checks.sh index 0714c6f74f0c2..091e1e4da0b8f 100755 --- a/ci/code_checks.sh +++ b/ci/code_checks.sh @@ -113,12 +113,9 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then -i "pandas.Timedelta.max PR02" \ -i "pandas.Timedelta.min PR02" \ -i "pandas.Timedelta.resolution PR02" \ - -i "pandas.Timedelta.to_numpy PR01" \ -i "pandas.Timedelta.to_timedelta64 SA01" \ -i "pandas.Timedelta.total_seconds SA01" \ -i "pandas.Timedelta.view SA01" \ - -i "pandas.TimedeltaIndex.components SA01" \ - -i "pandas.TimedeltaIndex.microseconds SA01" \ -i "pandas.TimedeltaIndex.nanoseconds SA01" \ -i "pandas.TimedeltaIndex.seconds SA01" \ -i "pandas.TimedeltaIndex.to_pytimedelta RT03,SA01" \ diff --git a/pandas/_libs/tslibs/timedeltas.pyx b/pandas/_libs/tslibs/timedeltas.pyx index 36be1812b0187..ad6e50cf22272 100644 --- a/pandas/_libs/tslibs/timedeltas.pyx +++ b/pandas/_libs/tslibs/timedeltas.pyx @@ -1421,9 +1421,16 @@ cdef class _Timedelta(timedelta): """ Convert the Timedelta to a NumPy timedelta64. - This is an alias method for `Timedelta.to_timedelta64()`. The dtype and - copy parameters are available here only for compatibility. Their values - will not affect the return value. + This is an alias method for `Timedelta.to_timedelta64()`. + + Parameters + ---------- + dtype : NoneType + It is available here only for compatibility. Its value will not + affect the return value. + copy : bool, default False + It is available here only for compatibility. Its value will not + affect the return value. Returns ------- diff --git a/pandas/core/arrays/timedeltas.py b/pandas/core/arrays/timedeltas.py index b2cfbe7338c0d..1c327b2160d03 100644 --- a/pandas/core/arrays/timedeltas.py +++ b/pandas/core/arrays/timedeltas.py @@ -876,6 +876,12 @@ def to_pytimedelta(self) -> npt.NDArray[np.object_]: microseconds_docstring = textwrap.dedent( """Number of microseconds (>= 0 and less than 1 second) for each element. + See Also + -------- + pd.Timedelta.microseconds : Number of microseconds (>= 0 and less than 1 second). + pd.Timedelta.to_pytimedelta.microseconds : Number of microseconds (>= 0 and less + than 1 second) of a datetime.timedelta. + Examples -------- For Series: @@ -955,6 +961,12 @@ def components(self) -> DataFrame: ------- DataFrame + See Also + -------- + TimedeltaIndex.total_seconds : Return total duration expressed in seconds. + Timedelta.components : Return a components namedtuple-like of a single + timedelta. + Examples -------- >>> tdelta_idx = pd.to_timedelta(["1 day 3 min 2 us 42 ns"]) From cb73773b9420913262af553a17ec9c07edeb631a Mon Sep 17 00:00:00 2001 From: amanlai Date: Wed, 4 Sep 2024 20:25:43 -0700 Subject: [PATCH 2/3] removed trailing whitespace --- pandas/_libs/tslibs/timedeltas.pyx | 4 ++-- pandas/core/arrays/timedeltas.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pandas/_libs/tslibs/timedeltas.pyx b/pandas/_libs/tslibs/timedeltas.pyx index ad6e50cf22272..a7bc2de5ad837 100644 --- a/pandas/_libs/tslibs/timedeltas.pyx +++ b/pandas/_libs/tslibs/timedeltas.pyx @@ -1426,10 +1426,10 @@ cdef class _Timedelta(timedelta): Parameters ---------- dtype : NoneType - It is available here only for compatibility. Its value will not + It is available here only for compatibility. Its value will not affect the return value. copy : bool, default False - It is available here only for compatibility. Its value will not + It is available here only for compatibility. Its value will not affect the return value. Returns diff --git a/pandas/core/arrays/timedeltas.py b/pandas/core/arrays/timedeltas.py index 1c327b2160d03..c8a86ffc187d0 100644 --- a/pandas/core/arrays/timedeltas.py +++ b/pandas/core/arrays/timedeltas.py @@ -879,7 +879,7 @@ def to_pytimedelta(self) -> npt.NDArray[np.object_]: See Also -------- pd.Timedelta.microseconds : Number of microseconds (>= 0 and less than 1 second). - pd.Timedelta.to_pytimedelta.microseconds : Number of microseconds (>= 0 and less + pd.Timedelta.to_pytimedelta.microseconds : Number of microseconds (>= 0 and less than 1 second) of a datetime.timedelta. Examples @@ -964,7 +964,7 @@ def components(self) -> DataFrame: See Also -------- TimedeltaIndex.total_seconds : Return total duration expressed in seconds. - Timedelta.components : Return a components namedtuple-like of a single + Timedelta.components : Return a components namedtuple-like of a single timedelta. Examples From 1bcbcbaece0e20cb1ad47df318c2e7c6c1fc345d Mon Sep 17 00:00:00 2001 From: amanlai Date: Thu, 5 Sep 2024 15:43:45 -0700 Subject: [PATCH 3/3] pd.Series.dt.microseconds has the same documentation as pd.TimedeltaIndex.microseconds and SA01 was cleared for both in the previous commit --- ci/code_checks.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/ci/code_checks.sh b/ci/code_checks.sh index 091e1e4da0b8f..fcbeb20d083d6 100755 --- a/ci/code_checks.sh +++ b/ci/code_checks.sh @@ -92,7 +92,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then -i "pandas.Series.dt.day_name PR01,PR02" \ -i "pandas.Series.dt.floor PR01,PR02" \ -i "pandas.Series.dt.freq GL08" \ - -i "pandas.Series.dt.microseconds SA01" \ -i "pandas.Series.dt.month_name PR01,PR02" \ -i "pandas.Series.dt.nanoseconds SA01" \ -i "pandas.Series.dt.normalize PR01" \