diff --git a/asv_bench/benchmarks/tslibs/offsets.py b/asv_bench/benchmarks/tslibs/offsets.py index 978a36e470cbb..a3fdaf8afdda1 100644 --- a/asv_bench/benchmarks/tslibs/offsets.py +++ b/asv_bench/benchmarks/tslibs/offsets.py @@ -71,11 +71,8 @@ def setup(self, offset): self.date = datetime(2011, 1, 1) self.dt64 = np.datetime64("2011-01-01 09:00Z") - def time_apply(self, offset): - offset.apply(self.date) - - def time_apply_np_dt64(self, offset): - offset.apply(self.dt64) + def time_add_np_dt64(self, offset): + offset + self.dt64 def time_add(self, offset): self.date + offset diff --git a/doc/source/reference/offset_frequency.rst b/doc/source/reference/offset_frequency.rst index f0e531cd81f84..ab89fe74e7337 100644 --- a/doc/source/reference/offset_frequency.rst +++ b/doc/source/reference/offset_frequency.rst @@ -34,14 +34,9 @@ Methods .. autosummary:: :toctree: api/ - DateOffset.apply - DateOffset.apply_index DateOffset.copy - DateOffset.isAnchored - DateOffset.onOffset DateOffset.is_anchored DateOffset.is_on_offset - DateOffset.__call__ DateOffset.is_month_start DateOffset.is_month_end DateOffset.is_quarter_start @@ -86,14 +81,9 @@ Methods .. autosummary:: :toctree: api/ - BusinessDay.apply - BusinessDay.apply_index BusinessDay.copy - BusinessDay.isAnchored - BusinessDay.onOffset BusinessDay.is_anchored BusinessDay.is_on_offset - BusinessDay.__call__ BusinessDay.is_month_start BusinessDay.is_month_end BusinessDay.is_quarter_start @@ -131,14 +121,9 @@ Methods .. autosummary:: :toctree: api/ - BusinessHour.apply - BusinessHour.apply_index BusinessHour.copy - BusinessHour.isAnchored - BusinessHour.onOffset BusinessHour.is_anchored BusinessHour.is_on_offset - BusinessHour.__call__ BusinessHour.is_month_start BusinessHour.is_month_end BusinessHour.is_quarter_start @@ -183,14 +168,9 @@ Methods .. autosummary:: :toctree: api/ - CustomBusinessDay.apply_index - CustomBusinessDay.apply CustomBusinessDay.copy - CustomBusinessDay.isAnchored - CustomBusinessDay.onOffset CustomBusinessDay.is_anchored CustomBusinessDay.is_on_offset - CustomBusinessDay.__call__ CustomBusinessDay.is_month_start CustomBusinessDay.is_month_end CustomBusinessDay.is_quarter_start @@ -228,14 +208,9 @@ Methods .. autosummary:: :toctree: api/ - CustomBusinessHour.apply - CustomBusinessHour.apply_index CustomBusinessHour.copy - CustomBusinessHour.isAnchored - CustomBusinessHour.onOffset CustomBusinessHour.is_anchored CustomBusinessHour.is_on_offset - CustomBusinessHour.__call__ CustomBusinessHour.is_month_start CustomBusinessHour.is_month_end CustomBusinessHour.is_quarter_start @@ -268,14 +243,9 @@ Methods .. autosummary:: :toctree: api/ - MonthEnd.apply - MonthEnd.apply_index MonthEnd.copy - MonthEnd.isAnchored - MonthEnd.onOffset MonthEnd.is_anchored MonthEnd.is_on_offset - MonthEnd.__call__ MonthEnd.is_month_start MonthEnd.is_month_end MonthEnd.is_quarter_start @@ -308,14 +278,9 @@ Methods .. autosummary:: :toctree: api/ - MonthBegin.apply - MonthBegin.apply_index MonthBegin.copy - MonthBegin.isAnchored - MonthBegin.onOffset MonthBegin.is_anchored MonthBegin.is_on_offset - MonthBegin.__call__ MonthBegin.is_month_start MonthBegin.is_month_end MonthBegin.is_quarter_start @@ -357,14 +322,9 @@ Methods .. autosummary:: :toctree: api/ - BusinessMonthEnd.apply - BusinessMonthEnd.apply_index BusinessMonthEnd.copy - BusinessMonthEnd.isAnchored - BusinessMonthEnd.onOffset BusinessMonthEnd.is_anchored BusinessMonthEnd.is_on_offset - BusinessMonthEnd.__call__ BusinessMonthEnd.is_month_start BusinessMonthEnd.is_month_end BusinessMonthEnd.is_quarter_start @@ -406,14 +366,9 @@ Methods .. autosummary:: :toctree: api/ - BusinessMonthBegin.apply - BusinessMonthBegin.apply_index BusinessMonthBegin.copy - BusinessMonthBegin.isAnchored - BusinessMonthBegin.onOffset BusinessMonthBegin.is_anchored BusinessMonthBegin.is_on_offset - BusinessMonthBegin.__call__ BusinessMonthBegin.is_month_start BusinessMonthBegin.is_month_end BusinessMonthBegin.is_quarter_start @@ -459,14 +414,9 @@ Methods .. autosummary:: :toctree: api/ - CustomBusinessMonthEnd.apply - CustomBusinessMonthEnd.apply_index CustomBusinessMonthEnd.copy - CustomBusinessMonthEnd.isAnchored - CustomBusinessMonthEnd.onOffset CustomBusinessMonthEnd.is_anchored CustomBusinessMonthEnd.is_on_offset - CustomBusinessMonthEnd.__call__ CustomBusinessMonthEnd.is_month_start CustomBusinessMonthEnd.is_month_end CustomBusinessMonthEnd.is_quarter_start @@ -512,14 +462,9 @@ Methods .. autosummary:: :toctree: api/ - CustomBusinessMonthBegin.apply - CustomBusinessMonthBegin.apply_index CustomBusinessMonthBegin.copy - CustomBusinessMonthBegin.isAnchored - CustomBusinessMonthBegin.onOffset CustomBusinessMonthBegin.is_anchored CustomBusinessMonthBegin.is_on_offset - CustomBusinessMonthBegin.__call__ CustomBusinessMonthBegin.is_month_start CustomBusinessMonthBegin.is_month_end CustomBusinessMonthBegin.is_quarter_start @@ -553,14 +498,9 @@ Methods .. autosummary:: :toctree: api/ - SemiMonthEnd.apply - SemiMonthEnd.apply_index SemiMonthEnd.copy - SemiMonthEnd.isAnchored - SemiMonthEnd.onOffset SemiMonthEnd.is_anchored SemiMonthEnd.is_on_offset - SemiMonthEnd.__call__ SemiMonthEnd.is_month_start SemiMonthEnd.is_month_end SemiMonthEnd.is_quarter_start @@ -594,14 +534,9 @@ Methods .. autosummary:: :toctree: api/ - SemiMonthBegin.apply - SemiMonthBegin.apply_index SemiMonthBegin.copy - SemiMonthBegin.isAnchored - SemiMonthBegin.onOffset SemiMonthBegin.is_anchored SemiMonthBegin.is_on_offset - SemiMonthBegin.__call__ SemiMonthBegin.is_month_start SemiMonthBegin.is_month_end SemiMonthBegin.is_quarter_start @@ -635,14 +570,9 @@ Methods .. autosummary:: :toctree: api/ - Week.apply - Week.apply_index Week.copy - Week.isAnchored - Week.onOffset Week.is_anchored Week.is_on_offset - Week.__call__ Week.is_month_start Week.is_month_end Week.is_quarter_start @@ -676,14 +606,9 @@ Methods .. autosummary:: :toctree: api/ - WeekOfMonth.apply - WeekOfMonth.apply_index WeekOfMonth.copy - WeekOfMonth.isAnchored - WeekOfMonth.onOffset WeekOfMonth.is_anchored WeekOfMonth.is_on_offset - WeekOfMonth.__call__ WeekOfMonth.weekday WeekOfMonth.is_month_start WeekOfMonth.is_month_end @@ -719,14 +644,9 @@ Methods .. autosummary:: :toctree: api/ - LastWeekOfMonth.apply - LastWeekOfMonth.apply_index LastWeekOfMonth.copy - LastWeekOfMonth.isAnchored - LastWeekOfMonth.onOffset LastWeekOfMonth.is_anchored LastWeekOfMonth.is_on_offset - LastWeekOfMonth.__call__ LastWeekOfMonth.is_month_start LastWeekOfMonth.is_month_end LastWeekOfMonth.is_quarter_start @@ -760,14 +680,9 @@ Methods .. autosummary:: :toctree: api/ - BQuarterEnd.apply - BQuarterEnd.apply_index BQuarterEnd.copy - BQuarterEnd.isAnchored - BQuarterEnd.onOffset BQuarterEnd.is_anchored BQuarterEnd.is_on_offset - BQuarterEnd.__call__ BQuarterEnd.is_month_start BQuarterEnd.is_month_end BQuarterEnd.is_quarter_start @@ -801,14 +716,9 @@ Methods .. autosummary:: :toctree: api/ - BQuarterBegin.apply - BQuarterBegin.apply_index BQuarterBegin.copy - BQuarterBegin.isAnchored - BQuarterBegin.onOffset BQuarterBegin.is_anchored BQuarterBegin.is_on_offset - BQuarterBegin.__call__ BQuarterBegin.is_month_start BQuarterBegin.is_month_end BQuarterBegin.is_quarter_start @@ -842,14 +752,9 @@ Methods .. autosummary:: :toctree: api/ - QuarterEnd.apply - QuarterEnd.apply_index QuarterEnd.copy - QuarterEnd.isAnchored - QuarterEnd.onOffset QuarterEnd.is_anchored QuarterEnd.is_on_offset - QuarterEnd.__call__ QuarterEnd.is_month_start QuarterEnd.is_month_end QuarterEnd.is_quarter_start @@ -883,14 +788,9 @@ Methods .. autosummary:: :toctree: api/ - QuarterBegin.apply - QuarterBegin.apply_index QuarterBegin.copy - QuarterBegin.isAnchored - QuarterBegin.onOffset QuarterBegin.is_anchored QuarterBegin.is_on_offset - QuarterBegin.__call__ QuarterBegin.is_month_start QuarterBegin.is_month_end QuarterBegin.is_quarter_start @@ -924,14 +824,9 @@ Methods .. autosummary:: :toctree: api/ - BYearEnd.apply - BYearEnd.apply_index BYearEnd.copy - BYearEnd.isAnchored - BYearEnd.onOffset BYearEnd.is_anchored BYearEnd.is_on_offset - BYearEnd.__call__ BYearEnd.is_month_start BYearEnd.is_month_end BYearEnd.is_quarter_start @@ -965,14 +860,9 @@ Methods .. autosummary:: :toctree: api/ - BYearBegin.apply - BYearBegin.apply_index BYearBegin.copy - BYearBegin.isAnchored - BYearBegin.onOffset BYearBegin.is_anchored BYearBegin.is_on_offset - BYearBegin.__call__ BYearBegin.is_month_start BYearBegin.is_month_end BYearBegin.is_quarter_start @@ -1006,14 +896,9 @@ Methods .. autosummary:: :toctree: api/ - YearEnd.apply - YearEnd.apply_index YearEnd.copy - YearEnd.isAnchored - YearEnd.onOffset YearEnd.is_anchored YearEnd.is_on_offset - YearEnd.__call__ YearEnd.is_month_start YearEnd.is_month_end YearEnd.is_quarter_start @@ -1047,14 +932,9 @@ Methods .. autosummary:: :toctree: api/ - YearBegin.apply - YearBegin.apply_index YearBegin.copy - YearBegin.isAnchored - YearBegin.onOffset YearBegin.is_anchored YearBegin.is_on_offset - YearBegin.__call__ YearBegin.is_month_start YearBegin.is_month_end YearBegin.is_quarter_start @@ -1090,16 +970,11 @@ Methods .. autosummary:: :toctree: api/ - FY5253.apply - FY5253.apply_index FY5253.copy FY5253.get_rule_code_suffix FY5253.get_year_end - FY5253.isAnchored - FY5253.onOffset FY5253.is_anchored FY5253.is_on_offset - FY5253.__call__ FY5253.is_month_start FY5253.is_month_end FY5253.is_quarter_start @@ -1136,17 +1011,12 @@ Methods .. autosummary:: :toctree: api/ - FY5253Quarter.apply - FY5253Quarter.apply_index FY5253Quarter.copy FY5253Quarter.get_rule_code_suffix FY5253Quarter.get_weeks - FY5253Quarter.isAnchored - FY5253Quarter.onOffset FY5253Quarter.is_anchored FY5253Quarter.is_on_offset FY5253Quarter.year_has_extra_week - FY5253Quarter.__call__ FY5253Quarter.is_month_start FY5253Quarter.is_month_end FY5253Quarter.is_quarter_start @@ -1179,14 +1049,9 @@ Methods .. autosummary:: :toctree: api/ - Easter.apply - Easter.apply_index Easter.copy - Easter.isAnchored - Easter.onOffset Easter.is_anchored Easter.is_on_offset - Easter.__call__ Easter.is_month_start Easter.is_month_end Easter.is_quarter_start @@ -1221,13 +1086,8 @@ Methods :toctree: api/ Tick.copy - Tick.isAnchored - Tick.onOffset Tick.is_anchored Tick.is_on_offset - Tick.__call__ - Tick.apply - Tick.apply_index Tick.is_month_start Tick.is_month_end Tick.is_quarter_start @@ -1262,13 +1122,8 @@ Methods :toctree: api/ Day.copy - Day.isAnchored - Day.onOffset Day.is_anchored Day.is_on_offset - Day.__call__ - Day.apply - Day.apply_index Day.is_month_start Day.is_month_end Day.is_quarter_start @@ -1303,13 +1158,8 @@ Methods :toctree: api/ Hour.copy - Hour.isAnchored - Hour.onOffset Hour.is_anchored Hour.is_on_offset - Hour.__call__ - Hour.apply - Hour.apply_index Hour.is_month_start Hour.is_month_end Hour.is_quarter_start @@ -1344,13 +1194,8 @@ Methods :toctree: api/ Minute.copy - Minute.isAnchored - Minute.onOffset Minute.is_anchored Minute.is_on_offset - Minute.__call__ - Minute.apply - Minute.apply_index Minute.is_month_start Minute.is_month_end Minute.is_quarter_start @@ -1385,13 +1230,8 @@ Methods :toctree: api/ Second.copy - Second.isAnchored - Second.onOffset Second.is_anchored Second.is_on_offset - Second.__call__ - Second.apply - Second.apply_index Second.is_month_start Second.is_month_end Second.is_quarter_start @@ -1426,13 +1266,8 @@ Methods :toctree: api/ Milli.copy - Milli.isAnchored - Milli.onOffset Milli.is_anchored Milli.is_on_offset - Milli.__call__ - Milli.apply - Milli.apply_index Milli.is_month_start Milli.is_month_end Milli.is_quarter_start @@ -1467,13 +1302,8 @@ Methods :toctree: api/ Micro.copy - Micro.isAnchored - Micro.onOffset Micro.is_anchored Micro.is_on_offset - Micro.__call__ - Micro.apply - Micro.apply_index Micro.is_month_start Micro.is_month_end Micro.is_quarter_start @@ -1508,13 +1338,8 @@ Methods :toctree: api/ Nano.copy - Nano.isAnchored - Nano.onOffset Nano.is_anchored Nano.is_on_offset - Nano.__call__ - Nano.apply - Nano.apply_index Nano.is_month_start Nano.is_month_end Nano.is_quarter_start diff --git a/doc/source/whatsnew/v2.0.0.rst b/doc/source/whatsnew/v2.0.0.rst index 00e57d738ca6e..0cb3145717fee 100644 --- a/doc/source/whatsnew/v2.0.0.rst +++ b/doc/source/whatsnew/v2.0.0.rst @@ -149,7 +149,6 @@ Other API changes Deprecations ~~~~~~~~~~~~ - -- .. --------------------------------------------------------------------------- @@ -173,6 +172,7 @@ Removal of prior version deprecations/changes :func:`~pandas.io.date_converters.parse_date_fields`, :func:`~pandas.io.date_converters.parse_all_fields` and :func:`~pandas.io.date_converters.generic_parser` (:issue:`24518`) - Remove argument ``squeeze`` from :meth:`DataFrame.groupby` and :meth:`Series.groupby` (:issue:`32380`) +- Removed deprecated ``apply``, ``apply_index``, ``__call__``, ``onOffset``, and ``isAnchored`` attributes from :class:`DateOffset` (:issue:`34171`) - Removed ``keep_tz`` argument in :meth:`DatetimeIndex.to_series` (:issue:`29731`) - Remove arguments ``names`` and ``dtype`` from :meth:`Index.copy` and ``levels`` and ``codes`` from :meth:`MultiIndex.copy` (:issue:`35853`, :issue:`36685`) - Remove argument ``inplace`` from :meth:`MultiIndex.set_levels` and :meth:`MultiIndex.set_codes` (:issue:`35626`) diff --git a/pandas/_libs/tslibs/offsets.pyi b/pandas/_libs/tslibs/offsets.pyi index 9317a371cc344..44e7e983b4038 100644 --- a/pandas/_libs/tslibs/offsets.pyi +++ b/pandas/_libs/tslibs/offsets.pyi @@ -3,7 +3,6 @@ from datetime import ( timedelta, ) from typing import ( - TYPE_CHECKING, Any, Collection, Literal, @@ -17,8 +16,6 @@ from pandas._typing import npt from .timedeltas import Timedelta -if TYPE_CHECKING: - from pandas.core.indexes.datetimes import DatetimeIndex _BaseOffsetT = TypeVar("_BaseOffsetT", bound=BaseOffset) _DatetimeT = TypeVar("_DatetimeT", bound=datetime) _TimedeltaT = TypeVar("_TimedeltaT", bound=timedelta) @@ -63,7 +60,6 @@ class BaseOffset: def __rsub__(self, other: _DatetimeT) -> _DatetimeT: ... @overload def __rsub__(self, other: _TimedeltaT) -> _TimedeltaT: ... - def __call__(self, other): ... @overload def __mul__(self, other: np.ndarray) -> np.ndarray: ... @overload @@ -80,7 +76,6 @@ class BaseOffset: def rule_code(self) -> str: ... @property def freqstr(self) -> str: ... - def apply_index(self, dtindex: DatetimeIndex) -> DatetimeIndex: ... def _apply(self, other): ... def _apply_array(self, dtarr) -> None: ... def rollback(self, dt: datetime) -> datetime: ... @@ -90,8 +85,6 @@ class BaseOffset: def __getstate__(self): ... @property def nanos(self) -> int: ... - def onOffset(self, dt: datetime) -> bool: ... - def isAnchored(self) -> bool: ... def is_anchored(self) -> bool: ... def _get_offset(name: str) -> BaseOffset: ... diff --git a/pandas/_libs/tslibs/offsets.pyx b/pandas/_libs/tslibs/offsets.pyx index 8bdd3d6ac259e..37b87f92971cc 100644 --- a/pandas/_libs/tslibs/offsets.pyx +++ b/pandas/_libs/tslibs/offsets.pyx @@ -1,8 +1,5 @@ import re import time -import warnings - -from pandas.util._exceptions import find_stack_level cimport cython from cpython.datetime cimport ( @@ -495,25 +492,6 @@ cdef class BaseOffset: def __rsub__(self, other): return (-self).__add__(other) - def __call__(self, other): - warnings.warn( - "DateOffset.__call__ is deprecated and will be removed in a future " - "version. Use `offset + other` instead.", - FutureWarning, - stacklevel=find_stack_level(), - ) - return self._apply(other) - - def apply(self, other): - # GH#44522 - warnings.warn( - f"{type(self).__name__}.apply is deprecated and will be removed " - "in a future version. Use `offset + other` instead", - FutureWarning, - stacklevel=find_stack_level(), - ) - return self._apply(other) - def __mul__(self, other): if util.is_array(other): return np.array([self * x for x in other]) @@ -652,34 +630,6 @@ cdef class BaseOffset: # ------------------------------------------------------------------ - def apply_index(self, dtindex): - """ - Vectorized apply of DateOffset to DatetimeIndex. - - .. deprecated:: 1.1.0 - - Use ``offset + dtindex`` instead. - - Parameters - ---------- - index : DatetimeIndex - - Returns - ------- - DatetimeIndex - - Raises - ------ - NotImplementedError - When the specific offset subclass does not have a vectorized - implementation. - """ - warnings.warn("'Offset.apply_index(other)' is deprecated. " - "Use 'offset + other' instead.", FutureWarning) - - res = self._apply_array(dtindex) - return type(dtindex)(res) - def _apply(self, other): raise NotImplementedError("implemented by subclasses") @@ -820,22 +770,6 @@ cdef class BaseOffset: def nanos(self): raise ValueError(f"{self} is a non-fixed frequency") - def onOffset(self, dt) -> bool: - warnings.warn( - "onOffset is a deprecated, use is_on_offset instead.", - FutureWarning, - stacklevel=find_stack_level(), - ) - return self.is_on_offset(dt) - - def isAnchored(self) -> bool: - warnings.warn( - "isAnchored is a deprecated, use is_anchored instead.", - FutureWarning, - stacklevel=find_stack_level(), - ) - return self.is_anchored() - def is_anchored(self) -> bool: # TODO: Does this make sense for the general case? It would help # if there were a canonical docstring for what is_anchored means. diff --git a/pandas/tests/tseries/offsets/test_business_day.py b/pandas/tests/tseries/offsets/test_business_day.py index a03a16ce7ffe7..243d3005e4f1d 100644 --- a/pandas/tests/tseries/offsets/test_business_day.py +++ b/pandas/tests/tseries/offsets/test_business_day.py @@ -96,11 +96,9 @@ def test_eq(self, offset2): def test_hash(self, offset2): assert hash(offset2) == hash(offset2) - def test_call(self, dt, offset2): - with tm.assert_produces_warning(FutureWarning): - # GH#34171 DateOffset.__call__ is deprecated - assert offset2(dt) == datetime(2008, 1, 3) - assert offset2(np.datetime64("2008-01-01 00:00:00")) == datetime(2008, 1, 3) + def test_add_datetime(self, dt, offset2): + assert offset2 + dt == datetime(2008, 1, 3) + assert offset2 + np.datetime64("2008-01-01 00:00:00") == datetime(2008, 1, 3) def testRollback1(self, dt, _offset): assert _offset(10).rollback(dt) == dt diff --git a/pandas/tests/tseries/offsets/test_business_hour.py b/pandas/tests/tseries/offsets/test_business_hour.py index cfd86d2098172..79e7a5ff67010 100644 --- a/pandas/tests/tseries/offsets/test_business_hour.py +++ b/pandas/tests/tseries/offsets/test_business_hour.py @@ -213,29 +213,24 @@ def test_hash(self, offset_name, request): offset = request.getfixturevalue(offset_name) assert offset == offset - def test_call( + def test_add_datetime( self, dt, offset1, offset2, offset3, offset4, - offset5, - offset6, - offset7, offset8, offset9, offset10, ): - with tm.assert_produces_warning(FutureWarning): - # GH#34171 DateOffset.__call__ is deprecated - assert offset1(dt) == datetime(2014, 7, 1, 11) - assert offset2(dt) == datetime(2014, 7, 1, 13) - assert offset3(dt) == datetime(2014, 6, 30, 17) - assert offset4(dt) == datetime(2014, 6, 30, 14) - assert offset8(dt) == datetime(2014, 7, 1, 11) - assert offset9(dt) == datetime(2014, 7, 1, 22) - assert offset10(dt) == datetime(2014, 7, 1, 1) + assert offset1 + dt == datetime(2014, 7, 1, 11) + assert offset2 + dt == datetime(2014, 7, 1, 13) + assert offset3 + dt == datetime(2014, 6, 30, 17) + assert offset4 + dt == datetime(2014, 6, 30, 14) + assert offset8 + dt == datetime(2014, 7, 1, 11) + assert offset9 + dt == datetime(2014, 7, 1, 22) + assert offset10 + dt == datetime(2014, 7, 1, 1) def test_sub(self, dt, offset2, _offset): off = offset2 diff --git a/pandas/tests/tseries/offsets/test_custom_business_hour.py b/pandas/tests/tseries/offsets/test_custom_business_hour.py index 203a860998722..38b5d74fe170f 100644 --- a/pandas/tests/tseries/offsets/test_custom_business_hour.py +++ b/pandas/tests/tseries/offsets/test_custom_business_hour.py @@ -18,7 +18,6 @@ Nano, ) -import pandas._testing as tm from pandas.tests.tseries.offsets.common import assert_offset_equal from pandas.tseries.holiday import USFederalHolidayCalendar @@ -101,11 +100,9 @@ def test_hash(self, offset1, offset2): assert hash(offset1) == hash(offset1) assert hash(offset2) == hash(offset2) - def test_call(self, dt, offset1, offset2): - with tm.assert_produces_warning(FutureWarning): - # GH#34171 DateOffset.__call__ is deprecated - assert offset1(dt) == datetime(2014, 7, 1, 11) - assert offset2(dt) == datetime(2014, 7, 1, 11) + def test_add_dateime(self, dt, offset1, offset2): + assert offset1 + dt == datetime(2014, 7, 1, 11) + assert offset2 + dt == datetime(2014, 7, 1, 11) def testRollback1(self, dt, offset1, offset2): assert offset1.rollback(dt) == dt diff --git a/pandas/tests/tseries/offsets/test_custom_business_month.py b/pandas/tests/tseries/offsets/test_custom_business_month.py index e70eddcc71d4c..36c690e89256d 100644 --- a/pandas/tests/tseries/offsets/test_custom_business_month.py +++ b/pandas/tests/tseries/offsets/test_custom_business_month.py @@ -89,10 +89,8 @@ def test_repr(self, offset, offset2): assert repr(offset) == "" assert repr(offset2) == "<2 * CustomBusinessMonthBegins>" - def test_call(self, dt, offset2): - with tm.assert_produces_warning(FutureWarning): - # GH#34171 DateOffset.__call__ is deprecated - assert offset2(dt) == datetime(2008, 3, 3) + def test_add_datetime(self, dt, offset2): + assert offset2 + dt == datetime(2008, 3, 3) def testRollback1(self): assert CDay(10).rollback(datetime(2007, 12, 31)) == datetime(2007, 12, 31) @@ -289,10 +287,8 @@ def test_repr(self, offset, offset2): assert repr(offset) == "" assert repr(offset2) == "<2 * CustomBusinessMonthEnds>" - def test_call(self, dt, offset2): - with tm.assert_produces_warning(FutureWarning): - # GH#34171 DateOffset.__call__ is deprecated - assert offset2(dt) == datetime(2008, 2, 29) + def test_add_datetime(self, dt, offset2): + assert offset2 + dt == datetime(2008, 2, 29) def testRollback1(self): assert CDay(10).rollback(datetime(2007, 12, 31)) == datetime(2007, 12, 31) diff --git a/pandas/tests/tseries/offsets/test_month.py b/pandas/tests/tseries/offsets/test_month.py index a1b7f710c3b24..e1bed2285bcdc 100644 --- a/pandas/tests/tseries/offsets/test_month.py +++ b/pandas/tests/tseries/offsets/test_month.py @@ -223,10 +223,6 @@ def test_apply_index(self, case): result = offset + shift tm.assert_index_equal(result, exp) - with tm.assert_produces_warning(FutureWarning): - result = offset.apply_index(shift) - tm.assert_index_equal(result, exp) - on_offset_cases = [ (datetime(2007, 12, 31), True), (datetime(2007, 12, 15), True), diff --git a/pandas/tests/tseries/offsets/test_offsets.py b/pandas/tests/tseries/offsets/test_offsets.py index ef45e354787ce..f1e511713d720 100644 --- a/pandas/tests/tseries/offsets/test_offsets.py +++ b/pandas/tests/tseries/offsets/test_offsets.py @@ -251,16 +251,6 @@ def _check_offsetfunc_works(self, offset, funcname, dt, expected, normalize=Fals with tm.assert_produces_warning(exp_warning): result = func(ts) - if exp_warning is None and funcname == "_apply": - # GH#44522 - # Check in this particular case to avoid headaches with - # testing for multiple warnings produced by the same call. - with tm.assert_produces_warning(FutureWarning, match="apply is deprecated"): - res2 = offset_s.apply(ts) - - assert type(res2) is type(result) - assert res2 == result - assert isinstance(result, Timestamp) if normalize is False: assert result == expected + Nano(5) @@ -571,27 +561,6 @@ def test_pickle_dateoffset_odd_inputs(self): base_dt = datetime(2020, 1, 1) assert base_dt + off == base_dt + res - def test_onOffset_deprecated(self, offset_types, fixed_now_ts): - # GH#30340 use idiomatic naming - off = _create_offset(offset_types) - - ts = fixed_now_ts - with tm.assert_produces_warning(FutureWarning): - result = off.onOffset(ts) - - expected = off.is_on_offset(ts) - assert result == expected - - def test_isAnchored_deprecated(self, offset_types): - # GH#30340 use idiomatic naming - off = _create_offset(offset_types) - - with tm.assert_produces_warning(FutureWarning): - result = off.isAnchored() - - expected = off.is_anchored() - assert result == expected - def test_offsets_hashable(self, offset_types): # GH: 37267 off = _create_offset(offset_types)