diff --git a/ci/code_checks.sh b/ci/code_checks.sh index a9967dcb8efe6..77778e8bbd859 100755 --- a/ci/code_checks.sh +++ b/ci/code_checks.sh @@ -1022,7 +1022,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then -i "pandas.tseries.offsets.DateOffset.rule_code GL08" \ -i "pandas.tseries.offsets.Day PR02" \ -i "pandas.tseries.offsets.Day.copy SA01" \ - -i "pandas.tseries.offsets.Day.delta GL08" \ -i "pandas.tseries.offsets.Day.freqstr SA01" \ -i "pandas.tseries.offsets.Day.is_on_offset GL08" \ -i "pandas.tseries.offsets.Day.kwds SA01" \ @@ -1075,7 +1074,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then -i "pandas.tseries.offsets.FY5253Quarter.year_has_extra_week GL08" \ -i "pandas.tseries.offsets.Hour PR02" \ -i "pandas.tseries.offsets.Hour.copy SA01" \ - -i "pandas.tseries.offsets.Hour.delta GL08" \ -i "pandas.tseries.offsets.Hour.freqstr SA01" \ -i "pandas.tseries.offsets.Hour.is_on_offset GL08" \ -i "pandas.tseries.offsets.Hour.kwds SA01" \ @@ -1098,7 +1096,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then -i "pandas.tseries.offsets.LastWeekOfMonth.weekday GL08" \ -i "pandas.tseries.offsets.Micro PR02" \ -i "pandas.tseries.offsets.Micro.copy SA01" \ - -i "pandas.tseries.offsets.Micro.delta GL08" \ -i "pandas.tseries.offsets.Micro.freqstr SA01" \ -i "pandas.tseries.offsets.Micro.is_on_offset GL08" \ -i "pandas.tseries.offsets.Micro.kwds SA01" \ @@ -1109,7 +1106,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then -i "pandas.tseries.offsets.Micro.rule_code GL08" \ -i "pandas.tseries.offsets.Milli PR02" \ -i "pandas.tseries.offsets.Milli.copy SA01" \ - -i "pandas.tseries.offsets.Milli.delta GL08" \ -i "pandas.tseries.offsets.Milli.freqstr SA01" \ -i "pandas.tseries.offsets.Milli.is_on_offset GL08" \ -i "pandas.tseries.offsets.Milli.kwds SA01" \ @@ -1120,7 +1116,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then -i "pandas.tseries.offsets.Milli.rule_code GL08" \ -i "pandas.tseries.offsets.Minute PR02" \ -i "pandas.tseries.offsets.Minute.copy SA01" \ - -i "pandas.tseries.offsets.Minute.delta GL08" \ -i "pandas.tseries.offsets.Minute.freqstr SA01" \ -i "pandas.tseries.offsets.Minute.is_on_offset GL08" \ -i "pandas.tseries.offsets.Minute.kwds SA01" \ @@ -1151,7 +1146,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then -i "pandas.tseries.offsets.MonthEnd.rule_code GL08" \ -i "pandas.tseries.offsets.Nano PR02" \ -i "pandas.tseries.offsets.Nano.copy SA01" \ - -i "pandas.tseries.offsets.Nano.delta GL08" \ -i "pandas.tseries.offsets.Nano.freqstr SA01" \ -i "pandas.tseries.offsets.Nano.is_on_offset GL08" \ -i "pandas.tseries.offsets.Nano.kwds SA01" \ @@ -1184,7 +1178,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then -i "pandas.tseries.offsets.QuarterEnd.startingMonth GL08" \ -i "pandas.tseries.offsets.Second PR02" \ -i "pandas.tseries.offsets.Second.copy SA01" \ - -i "pandas.tseries.offsets.Second.delta GL08" \ -i "pandas.tseries.offsets.Second.freqstr SA01" \ -i "pandas.tseries.offsets.Second.is_on_offset GL08" \ -i "pandas.tseries.offsets.Second.kwds SA01" \ @@ -1217,7 +1210,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then -i "pandas.tseries.offsets.SemiMonthEnd.rule_code GL08" \ -i "pandas.tseries.offsets.Tick GL08" \ -i "pandas.tseries.offsets.Tick.copy SA01" \ - -i "pandas.tseries.offsets.Tick.delta GL08" \ -i "pandas.tseries.offsets.Tick.freqstr SA01" \ -i "pandas.tseries.offsets.Tick.is_on_offset GL08" \ -i "pandas.tseries.offsets.Tick.kwds SA01" \ diff --git a/doc/source/reference/offset_frequency.rst b/doc/source/reference/offset_frequency.rst index 37eff247899be..8bb2c6ffe73be 100644 --- a/doc/source/reference/offset_frequency.rst +++ b/doc/source/reference/offset_frequency.rst @@ -1042,7 +1042,6 @@ Properties .. autosummary:: :toctree: api/ - Tick.delta Tick.freqstr Tick.kwds Tick.name @@ -1077,7 +1076,6 @@ Properties .. autosummary:: :toctree: api/ - Day.delta Day.freqstr Day.kwds Day.name @@ -1112,7 +1110,6 @@ Properties .. autosummary:: :toctree: api/ - Hour.delta Hour.freqstr Hour.kwds Hour.name @@ -1147,7 +1144,6 @@ Properties .. autosummary:: :toctree: api/ - Minute.delta Minute.freqstr Minute.kwds Minute.name @@ -1182,7 +1178,6 @@ Properties .. autosummary:: :toctree: api/ - Second.delta Second.freqstr Second.kwds Second.name @@ -1217,7 +1212,6 @@ Properties .. autosummary:: :toctree: api/ - Milli.delta Milli.freqstr Milli.kwds Milli.name @@ -1252,7 +1246,6 @@ Properties .. autosummary:: :toctree: api/ - Micro.delta Micro.freqstr Micro.kwds Micro.name @@ -1287,7 +1280,6 @@ Properties .. autosummary:: :toctree: api/ - Nano.delta Nano.freqstr Nano.kwds Nano.name diff --git a/doc/source/whatsnew/v3.0.0.rst b/doc/source/whatsnew/v3.0.0.rst index a398b93b60018..8b3d4fe8ff5e1 100644 --- a/doc/source/whatsnew/v3.0.0.rst +++ b/doc/source/whatsnew/v3.0.0.rst @@ -201,6 +201,7 @@ Removal of prior version deprecations/changes - Enforced deprecation disallowing parsing datetimes with mixed time zones unless user passes ``utc=True`` to :func:`to_datetime` (:issue:`57275`) - Enforced deprecation of :meth:`.DataFrameGroupBy.get_group` and :meth:`.SeriesGroupBy.get_group` allowing the ``name`` argument to be a non-tuple when grouping by a list of length 1 (:issue:`54155`) - Enforced deprecation of :meth:`Series.interpolate` and :meth:`DataFrame.interpolate` for object-dtype (:issue:`57820`) +- Enforced deprecation of :meth:`offsets.Tick.delta`, use ``pd.Timedelta(obj)`` instead (:issue:`55498`) - Enforced deprecation of ``axis=None`` acting the same as ``axis=0`` in the DataFrame reductions ``sum``, ``prod``, ``std``, ``var``, and ``sem``, passing ``axis=None`` will now reduce over both axes; this is particularly the case when doing e.g. ``numpy.sum(df)`` (:issue:`21597`) - Enforced deprecation of parsing system timezone strings to ``tzlocal``, which depended on system timezone, pass the 'tz' keyword instead (:issue:`50791`) - Enforced deprecation of passing a dictionary to :meth:`SeriesGroupBy.agg` (:issue:`52268`) diff --git a/pandas/_libs/tslibs/offsets.pyi b/pandas/_libs/tslibs/offsets.pyi index 791ebc0fbb245..3f942d6aa3622 100644 --- a/pandas/_libs/tslibs/offsets.pyi +++ b/pandas/_libs/tslibs/offsets.pyi @@ -20,8 +20,6 @@ from pandas._typing import ( npt, ) -from .timedeltas import Timedelta - _BaseOffsetT = TypeVar("_BaseOffsetT", bound=BaseOffset) _DatetimeT = TypeVar("_DatetimeT", bound=datetime) _TimedeltaT = TypeVar("_TimedeltaT", bound=timedelta) @@ -114,8 +112,6 @@ class Tick(SingleConstructorOffset): _prefix: str def __init__(self, n: int = ..., normalize: bool = ...) -> None: ... @property - def delta(self) -> Timedelta: ... - @property def nanos(self) -> int: ... def delta_to_tick(delta: timedelta) -> Tick: ... diff --git a/pandas/_libs/tslibs/offsets.pyx b/pandas/_libs/tslibs/offsets.pyx index fd18ae5908f10..e36abdf0ad971 100644 --- a/pandas/_libs/tslibs/offsets.pyx +++ b/pandas/_libs/tslibs/offsets.pyx @@ -957,22 +957,6 @@ cdef class Tick(SingleConstructorOffset): def _as_pd_timedelta(self): return Timedelta(self) - @property - def delta(self): - warnings.warn( - # GH#55498 - f"{type(self).__name__}.delta is deprecated and will be removed in " - "a future version. Use pd.Timedelta(obj) instead", - FutureWarning, - stacklevel=find_stack_level(), - ) - try: - return self.n * Timedelta(self._nanos_inc) - except OverflowError as err: - # GH#55503 as_unit will raise a more useful OutOfBoundsTimedelta - Timedelta(self).as_unit("ns") - raise AssertionError("This should not be reached.") - @property def nanos(self) -> int64_t: """ diff --git a/pandas/tests/tseries/offsets/test_ticks.py b/pandas/tests/tseries/offsets/test_ticks.py index c8fbdfa11991a..f91230e1460c4 100644 --- a/pandas/tests/tseries/offsets/test_ticks.py +++ b/pandas/tests/tseries/offsets/test_ticks.py @@ -16,7 +16,6 @@ import pytest from pandas._libs.tslibs.offsets import delta_to_tick -from pandas.errors import OutOfBoundsTimedelta from pandas import ( Timedelta, @@ -239,16 +238,6 @@ def test_tick_addition(kls, expected): assert result == expected -def test_tick_delta_overflow(): - # GH#55503 raise OutOfBoundsTimedelta, not OverflowError - tick = offsets.Day(10**9) - msg = "Cannot cast 1000000000 days 00:00:00 to unit='ns' without overflow" - depr_msg = "Day.delta is deprecated" - with pytest.raises(OutOfBoundsTimedelta, match=msg): - with tm.assert_produces_warning(FutureWarning, match=depr_msg): - tick.delta - - @pytest.mark.parametrize("cls", tick_classes) def test_tick_division(cls): off = cls(10)