Skip to content

Commit

Permalink
DEPR: Timedelta.delta (#46476)
Browse files Browse the repository at this point in the history
  • Loading branch information
jbrockmendel authored Mar 23, 2022
1 parent 6d7e004 commit 0aea13b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions doc/source/whatsnew/v1.5.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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`)
-

.. ---------------------------------------------------------------------------
Expand Down
6 changes: 6 additions & 0 deletions pandas/_libs/tslibs/timedeltas.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions pandas/tests/scalar/timedelta/test_timedelta.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 0aea13b

Please sign in to comment.