Skip to content

Commit e750856

Browse files
committed
update docstrings
1 parent 5ced458 commit e750856

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

ci/code_checks.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
101101
-i "pandas.Timedelta.max PR02" \
102102
-i "pandas.Timedelta.min PR02" \
103103
-i "pandas.Timedelta.resolution PR02" \
104-
-i "pandas.TimedeltaIndex.to_pytimedelta RT03,SA01" \
105104
-i "pandas.Timestamp.max PR02" \
106105
-i "pandas.Timestamp.min PR02" \
107106
-i "pandas.Timestamp.nanosecond GL08" \

pandas/core/arrays/timedeltas.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -789,7 +789,20 @@ def to_pytimedelta(self) -> npt.NDArray[np.object_]:
789789
790790
Returns
791791
-------
792-
numpy.ndarray
792+
**numpy.ndarray**
793+
A NumPy ``timedelta64`` object representing the same duration as the
794+
original pandas ``Timedelta`` object. The precision of the resulting
795+
object is in nanoseconds, which is the default
796+
time resolution used by pandas for ``Timedelta`` objects, ensuring
797+
high precision for time-based calculations.
798+
799+
See Also
800+
--------
801+
to_timedelta : Convert argument to timedelta format.
802+
Timedelta : Represents a duration between two dates or times.
803+
DatetimeIndex: Index of datetime64 data.
804+
Timedelta.components : Return a components namedtuple-like
805+
of a single timedelta.
793806
794807
Examples
795808
--------
@@ -800,6 +813,14 @@ def to_pytimedelta(self) -> npt.NDArray[np.object_]:
800813
>>> tdelta_idx.to_pytimedelta()
801814
array([datetime.timedelta(days=1), datetime.timedelta(days=2),
802815
datetime.timedelta(days=3)], dtype=object)
816+
817+
>>> tidx = pd.TimedeltaIndex(data=["1 days 02:30:45", "3 days 04:15:10"])
818+
>>> tidx
819+
TimedeltaIndex(['1 days 02:30:45', '3 days 04:15:10'],
820+
dtype='timedelta64[ns]', freq=None)
821+
>>> tidx.to_pytimedelta()
822+
array([datetime.timedelta(days=1, seconds=9045),
823+
datetime.timedelta(days=3, seconds=15310)], dtype=object)
803824
"""
804825
return ints_to_pytimedelta(self._ndarray)
805826

0 commit comments

Comments
 (0)