diff --git a/doc/source/whatsnew/v1.5.0.rst b/doc/source/whatsnew/v1.5.0.rst index af2f41284b259..50a5bf383de77 100644 --- a/doc/source/whatsnew/v1.5.0.rst +++ b/doc/source/whatsnew/v1.5.0.rst @@ -363,6 +363,7 @@ Other Deprecations - Deprecated treating all-bool ``object``-dtype columns as bool-like in :meth:`DataFrame.any` and :meth:`DataFrame.all` with ``bool_only=True``, explicitly cast to bool instead (:issue:`46188`) - Deprecated behavior of method :meth:`DataFrame.quantile`, attribute ``numeric_only`` will default False. Including datetime/timedelta columns in the result (:issue:`7308`). - Deprecated :attr:`Timedelta.freq` and :attr:`Timedelta.is_populated` (:issue:`46430`) +- Deprecated :attr:`Timedelta.delta` (:issue:`46476`) - .. --------------------------------------------------------------------------- diff --git a/pandas/_libs/tslibs/timedeltas.pyx b/pandas/_libs/tslibs/timedeltas.pyx index fa0db6a46deef..627006a7f32c0 100644 --- a/pandas/_libs/tslibs/timedeltas.pyx +++ b/pandas/_libs/tslibs/timedeltas.pyx @@ -1014,6 +1014,12 @@ cdef class _Timedelta(timedelta): >>> td.delta 42 """ + # Deprecated GH#46476 + warnings.warn( + "Timedelta.delta is deprecated and will be removed in a future version.", + FutureWarning, + stacklevel=1, + ) return self.value @property diff --git a/pandas/tests/scalar/timedelta/test_timedelta.py b/pandas/tests/scalar/timedelta/test_timedelta.py index 36520a1983aac..1ec93c69def99 100644 --- a/pandas/tests/scalar/timedelta/test_timedelta.py +++ b/pandas/tests/scalar/timedelta/test_timedelta.py @@ -681,3 +681,10 @@ def test_is_populated_deprecated(): with pytest.raises(AttributeError, match="is not writable"): td.is_populated = 1 + + +def test_delta_deprecated(): + # GH#46476 + td = Timedelta(123456546, unit="ns") + with tm.assert_produces_warning(FutureWarning, match="Timedelta.delta is"): + td.delta