From 73396803f69edb3ba3ccc8dc9982a0f36bf6926b Mon Sep 17 00:00:00 2001 From: Tuhin Sharma Date: Sun, 22 Sep 2024 10:55:42 +0530 Subject: [PATCH 1/2] DOC: fix SA01, ES01 for pandas.Timedelta.to_timedelta64 --- ci/code_checks.sh | 1 - pandas/_libs/tslibs/timedeltas.pyx | 12 ++++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/ci/code_checks.sh b/ci/code_checks.sh index f2d9f582d8932..3076e296d14e5 100755 --- a/ci/code_checks.sh +++ b/ci/code_checks.sh @@ -104,7 +104,6 @@ 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_timedelta64 SA01" \ -i "pandas.TimedeltaIndex.to_pytimedelta RT03,SA01" \ -i "pandas.Timestamp.max PR02" \ -i "pandas.Timestamp.min PR02" \ diff --git a/pandas/_libs/tslibs/timedeltas.pyx b/pandas/_libs/tslibs/timedeltas.pyx index 0ff5c5fb81df8..e5b08581c2c64 100644 --- a/pandas/_libs/tslibs/timedeltas.pyx +++ b/pandas/_libs/tslibs/timedeltas.pyx @@ -1411,6 +1411,18 @@ cdef class _Timedelta(timedelta): """ Return a numpy.timedelta64 object with 'ns' precision. + Since NumPy uses `timedelta64` objects for its time operations, converting + a pandas `Timedelta` into a NumPy `timedelta64` provides seamless integration + between the two libraries, especially when working in environments that + heavily rely on NumPy for array-based calculations. + + See Also + -------- + to_timedelta : Convert argument to timedelta. + numpy.timedelta64 : A NumPy object for time duration. + Timedelta : Represents a duration, the difference between two dates + or times. + Examples -------- >>> td = pd.Timedelta('3D') From 658c652b48ea13ec3b8152fab9a6ba51a1c18b47 Mon Sep 17 00:00:00 2001 From: Tuhin Sharma Date: Wed, 25 Sep 2024 23:30:14 +0530 Subject: [PATCH 2/2] DOC: add double backticks for sphinx compatibility Co-authored-by: mroeschke --- pandas/_libs/tslibs/timedeltas.pyx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pandas/_libs/tslibs/timedeltas.pyx b/pandas/_libs/tslibs/timedeltas.pyx index e5b08581c2c64..84ca48c96459f 100644 --- a/pandas/_libs/tslibs/timedeltas.pyx +++ b/pandas/_libs/tslibs/timedeltas.pyx @@ -1411,10 +1411,10 @@ cdef class _Timedelta(timedelta): """ Return a numpy.timedelta64 object with 'ns' precision. - Since NumPy uses `timedelta64` objects for its time operations, converting - a pandas `Timedelta` into a NumPy `timedelta64` provides seamless integration - between the two libraries, especially when working in environments that - heavily rely on NumPy for array-based calculations. + Since NumPy uses ``timedelta64`` objects for its time operations, converting + a pandas ``Timedelta`` into a NumPy ``timedelta64`` provides seamless + integration between the two libraries, especially when working in environments + that heavily rely on NumPy for array-based calculations. See Also --------