diff --git a/pandas/_libs/tslibs/timedeltas.pyi b/pandas/_libs/tslibs/timedeltas.pyi index b40b08eb601a4..d514a295215cb 100644 --- a/pandas/_libs/tslibs/timedeltas.pyi +++ b/pandas/_libs/tslibs/timedeltas.pyi @@ -150,6 +150,7 @@ class Timedelta(timedelta): def __hash__(self) -> int: ... def isoformat(self) -> str: ... def to_numpy(self) -> np.timedelta64: ... + def view(self, dtype: npt.DTypeLike = ...) -> object: ... @property def freq(self) -> None: ... @property diff --git a/pandas/_libs/tslibs/timedeltas.pyx b/pandas/_libs/tslibs/timedeltas.pyx index 3aaf321f301cb..32c8f535a845d 100644 --- a/pandas/_libs/tslibs/timedeltas.pyx +++ b/pandas/_libs/tslibs/timedeltas.pyx @@ -1240,6 +1240,11 @@ cdef class _Timedelta(timedelta): def view(self, dtype): """ Array view compatibility. + + Parameters + ---------- + dtype : str or dtype + The dtype to view the underlying data as. """ return np.timedelta64(self.value).view(dtype)