Skip to content

Commit 0aea13b

Browse files
authored
DEPR: Timedelta.delta (#46476)
1 parent 6d7e004 commit 0aea13b

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

doc/source/whatsnew/v1.5.0.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,7 @@ Other Deprecations
363363
- 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`)
364364
- Deprecated behavior of method :meth:`DataFrame.quantile`, attribute ``numeric_only`` will default False. Including datetime/timedelta columns in the result (:issue:`7308`).
365365
- Deprecated :attr:`Timedelta.freq` and :attr:`Timedelta.is_populated` (:issue:`46430`)
366+
- Deprecated :attr:`Timedelta.delta` (:issue:`46476`)
366367
-
367368

368369
.. ---------------------------------------------------------------------------

pandas/_libs/tslibs/timedeltas.pyx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1014,6 +1014,12 @@ cdef class _Timedelta(timedelta):
10141014
>>> td.delta
10151015
42
10161016
"""
1017+
# Deprecated GH#46476
1018+
warnings.warn(
1019+
"Timedelta.delta is deprecated and will be removed in a future version.",
1020+
FutureWarning,
1021+
stacklevel=1,
1022+
)
10171023
return self.value
10181024

10191025
@property

pandas/tests/scalar/timedelta/test_timedelta.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -681,3 +681,10 @@ def test_is_populated_deprecated():
681681

682682
with pytest.raises(AttributeError, match="is not writable"):
683683
td.is_populated = 1
684+
685+
686+
def test_delta_deprecated():
687+
# GH#46476
688+
td = Timedelta(123456546, unit="ns")
689+
with tm.assert_produces_warning(FutureWarning, match="Timedelta.delta is"):
690+
td.delta

0 commit comments

Comments
 (0)