diff --git a/doc/source/reference/offset_frequency.rst b/doc/source/reference/offset_frequency.rst index ab89fe74e7337..b5ddf2a214561 100644 --- a/doc/source/reference/offset_frequency.rst +++ b/doc/source/reference/offset_frequency.rst @@ -35,7 +35,6 @@ Methods :toctree: api/ DateOffset.copy - DateOffset.is_anchored DateOffset.is_on_offset DateOffset.is_month_start DateOffset.is_month_end @@ -82,7 +81,6 @@ Methods :toctree: api/ BusinessDay.copy - BusinessDay.is_anchored BusinessDay.is_on_offset BusinessDay.is_month_start BusinessDay.is_month_end @@ -122,7 +120,6 @@ Methods :toctree: api/ BusinessHour.copy - BusinessHour.is_anchored BusinessHour.is_on_offset BusinessHour.is_month_start BusinessHour.is_month_end @@ -169,7 +166,6 @@ Methods :toctree: api/ CustomBusinessDay.copy - CustomBusinessDay.is_anchored CustomBusinessDay.is_on_offset CustomBusinessDay.is_month_start CustomBusinessDay.is_month_end @@ -209,7 +205,6 @@ Methods :toctree: api/ CustomBusinessHour.copy - CustomBusinessHour.is_anchored CustomBusinessHour.is_on_offset CustomBusinessHour.is_month_start CustomBusinessHour.is_month_end @@ -244,7 +239,6 @@ Methods :toctree: api/ MonthEnd.copy - MonthEnd.is_anchored MonthEnd.is_on_offset MonthEnd.is_month_start MonthEnd.is_month_end @@ -279,7 +273,6 @@ Methods :toctree: api/ MonthBegin.copy - MonthBegin.is_anchored MonthBegin.is_on_offset MonthBegin.is_month_start MonthBegin.is_month_end @@ -323,7 +316,6 @@ Methods :toctree: api/ BusinessMonthEnd.copy - BusinessMonthEnd.is_anchored BusinessMonthEnd.is_on_offset BusinessMonthEnd.is_month_start BusinessMonthEnd.is_month_end @@ -367,7 +359,6 @@ Methods :toctree: api/ BusinessMonthBegin.copy - BusinessMonthBegin.is_anchored BusinessMonthBegin.is_on_offset BusinessMonthBegin.is_month_start BusinessMonthBegin.is_month_end @@ -415,7 +406,6 @@ Methods :toctree: api/ CustomBusinessMonthEnd.copy - CustomBusinessMonthEnd.is_anchored CustomBusinessMonthEnd.is_on_offset CustomBusinessMonthEnd.is_month_start CustomBusinessMonthEnd.is_month_end @@ -463,7 +453,6 @@ Methods :toctree: api/ CustomBusinessMonthBegin.copy - CustomBusinessMonthBegin.is_anchored CustomBusinessMonthBegin.is_on_offset CustomBusinessMonthBegin.is_month_start CustomBusinessMonthBegin.is_month_end @@ -499,7 +488,6 @@ Methods :toctree: api/ SemiMonthEnd.copy - SemiMonthEnd.is_anchored SemiMonthEnd.is_on_offset SemiMonthEnd.is_month_start SemiMonthEnd.is_month_end @@ -535,7 +523,6 @@ Methods :toctree: api/ SemiMonthBegin.copy - SemiMonthBegin.is_anchored SemiMonthBegin.is_on_offset SemiMonthBegin.is_month_start SemiMonthBegin.is_month_end @@ -571,7 +558,6 @@ Methods :toctree: api/ Week.copy - Week.is_anchored Week.is_on_offset Week.is_month_start Week.is_month_end @@ -607,7 +593,6 @@ Methods :toctree: api/ WeekOfMonth.copy - WeekOfMonth.is_anchored WeekOfMonth.is_on_offset WeekOfMonth.weekday WeekOfMonth.is_month_start @@ -645,7 +630,6 @@ Methods :toctree: api/ LastWeekOfMonth.copy - LastWeekOfMonth.is_anchored LastWeekOfMonth.is_on_offset LastWeekOfMonth.is_month_start LastWeekOfMonth.is_month_end @@ -681,7 +665,6 @@ Methods :toctree: api/ BQuarterEnd.copy - BQuarterEnd.is_anchored BQuarterEnd.is_on_offset BQuarterEnd.is_month_start BQuarterEnd.is_month_end @@ -717,7 +700,6 @@ Methods :toctree: api/ BQuarterBegin.copy - BQuarterBegin.is_anchored BQuarterBegin.is_on_offset BQuarterBegin.is_month_start BQuarterBegin.is_month_end @@ -753,7 +735,6 @@ Methods :toctree: api/ QuarterEnd.copy - QuarterEnd.is_anchored QuarterEnd.is_on_offset QuarterEnd.is_month_start QuarterEnd.is_month_end @@ -789,7 +770,6 @@ Methods :toctree: api/ QuarterBegin.copy - QuarterBegin.is_anchored QuarterBegin.is_on_offset QuarterBegin.is_month_start QuarterBegin.is_month_end @@ -825,7 +805,6 @@ Methods :toctree: api/ BYearEnd.copy - BYearEnd.is_anchored BYearEnd.is_on_offset BYearEnd.is_month_start BYearEnd.is_month_end @@ -861,7 +840,6 @@ Methods :toctree: api/ BYearBegin.copy - BYearBegin.is_anchored BYearBegin.is_on_offset BYearBegin.is_month_start BYearBegin.is_month_end @@ -897,7 +875,6 @@ Methods :toctree: api/ YearEnd.copy - YearEnd.is_anchored YearEnd.is_on_offset YearEnd.is_month_start YearEnd.is_month_end @@ -933,7 +910,6 @@ Methods :toctree: api/ YearBegin.copy - YearBegin.is_anchored YearBegin.is_on_offset YearBegin.is_month_start YearBegin.is_month_end @@ -973,7 +949,6 @@ Methods FY5253.copy FY5253.get_rule_code_suffix FY5253.get_year_end - FY5253.is_anchored FY5253.is_on_offset FY5253.is_month_start FY5253.is_month_end @@ -1014,7 +989,6 @@ Methods FY5253Quarter.copy FY5253Quarter.get_rule_code_suffix FY5253Quarter.get_weeks - FY5253Quarter.is_anchored FY5253Quarter.is_on_offset FY5253Quarter.year_has_extra_week FY5253Quarter.is_month_start @@ -1050,7 +1024,6 @@ Methods :toctree: api/ Easter.copy - Easter.is_anchored Easter.is_on_offset Easter.is_month_start Easter.is_month_end @@ -1086,7 +1059,6 @@ Methods :toctree: api/ Tick.copy - Tick.is_anchored Tick.is_on_offset Tick.is_month_start Tick.is_month_end @@ -1122,7 +1094,6 @@ Methods :toctree: api/ Day.copy - Day.is_anchored Day.is_on_offset Day.is_month_start Day.is_month_end @@ -1158,7 +1129,6 @@ Methods :toctree: api/ Hour.copy - Hour.is_anchored Hour.is_on_offset Hour.is_month_start Hour.is_month_end @@ -1194,7 +1164,6 @@ Methods :toctree: api/ Minute.copy - Minute.is_anchored Minute.is_on_offset Minute.is_month_start Minute.is_month_end @@ -1230,7 +1199,6 @@ Methods :toctree: api/ Second.copy - Second.is_anchored Second.is_on_offset Second.is_month_start Second.is_month_end @@ -1266,7 +1234,6 @@ Methods :toctree: api/ Milli.copy - Milli.is_anchored Milli.is_on_offset Milli.is_month_start Milli.is_month_end @@ -1302,7 +1269,6 @@ Methods :toctree: api/ Micro.copy - Micro.is_anchored Micro.is_on_offset Micro.is_month_start Micro.is_month_end @@ -1338,7 +1304,6 @@ Methods :toctree: api/ Nano.copy - Nano.is_anchored Nano.is_on_offset Nano.is_month_start Nano.is_month_end diff --git a/doc/source/whatsnew/v3.0.0.rst b/doc/source/whatsnew/v3.0.0.rst index 77c80dcfe7c7e..38d9523a5083a 100644 --- a/doc/source/whatsnew/v3.0.0.rst +++ b/doc/source/whatsnew/v3.0.0.rst @@ -118,6 +118,7 @@ Removal of prior version deprecations/changes - Changed the default value of ``observed`` in :meth:`DataFrame.groupby` and :meth:`Series.groupby` to ``True`` (:issue:`51811`) - Enforced silent-downcasting deprecation for :ref:`all relevant methods ` (:issue:`54710`) - In :meth:`DataFrame.stack`, the default value of ``future_stack`` is now ``True``; specifying ``False`` will raise a ``FutureWarning`` (:issue:`55448`) +- Removed :meth:`DateOffset.is_anchored` and :meth:`offsets.Tick.is_anchored` (:issue:`56594`) - Removed ``DataFrame.applymap``, ``Styler.applymap`` and ``Styler.applymap_index`` (:issue:`52364`) - Removed ``DataFrame.bool`` and ``Series.bool`` (:issue:`51756`) - Removed ``DataFrame.first`` and ``DataFrame.last`` (:issue:`53710`) diff --git a/pandas/_libs/tslibs/offsets.pyi b/pandas/_libs/tslibs/offsets.pyi index 434f10a00745f..8f1e34522c026 100644 --- a/pandas/_libs/tslibs/offsets.pyi +++ b/pandas/_libs/tslibs/offsets.pyi @@ -94,7 +94,6 @@ class BaseOffset: def __getstate__(self): ... @property def nanos(self) -> int: ... - 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 e96a905367f69..1afdb4f8b96fc 100644 --- a/pandas/_libs/tslibs/offsets.pyx +++ b/pandas/_libs/tslibs/offsets.pyx @@ -755,30 +755,6 @@ cdef class BaseOffset: def nanos(self): raise ValueError(f"{self} is a non-fixed frequency") - def is_anchored(self) -> bool: - # GH#55388 - """ - Return boolean whether the frequency is a unit frequency (n=1). - - .. deprecated:: 2.2.0 - is_anchored is deprecated and will be removed in a future version. - Use ``obj.n == 1`` instead. - - Examples - -------- - >>> pd.DateOffset().is_anchored() - True - >>> pd.DateOffset(2).is_anchored() - False - """ - warnings.warn( - f"{type(self).__name__}.is_anchored is deprecated and will be removed " - f"in a future version, please use \'obj.n == 1\' instead.", - FutureWarning, - stacklevel=find_stack_level(), - ) - return self.n == 1 - # ------------------------------------------------------------------ def is_month_start(self, _Timestamp ts): @@ -962,30 +938,6 @@ cdef class Tick(SingleConstructorOffset): def is_on_offset(self, dt: datetime) -> bool: return True - def is_anchored(self) -> bool: - # GH#55388 - """ - Return False. - - .. deprecated:: 2.2.0 - is_anchored is deprecated and will be removed in a future version. - Use ``False`` instead. - - Examples - -------- - >>> pd.offsets.Hour().is_anchored() - False - >>> pd.offsets.Hour(2).is_anchored() - False - """ - warnings.warn( - f"{type(self).__name__}.is_anchored is deprecated and will be removed " - f"in a future version, please use False instead.", - FutureWarning, - stacklevel=find_stack_level(), - ) - return False - # This is identical to BaseOffset.__hash__, but has to be redefined here # for Python 3, because we've redefined __eq__. def __hash__(self) -> int: @@ -2692,16 +2644,6 @@ cdef class QuarterOffset(SingleConstructorOffset): month = MONTH_ALIASES[self.startingMonth] return f"{self._prefix}-{month}" - def is_anchored(self) -> bool: - warnings.warn( - f"{type(self).__name__}.is_anchored is deprecated and will be removed " - f"in a future version, please use \'obj.n == 1 " - f"and obj.startingMonth is not None\' instead.", - FutureWarning, - stacklevel=find_stack_level(), - ) - return self.n == 1 and self.startingMonth is not None - def is_on_offset(self, dt: datetime) -> bool: if self.normalize and not _is_normalized(dt): return False @@ -3344,16 +3286,6 @@ cdef class Week(SingleConstructorOffset): self.weekday = state.pop("weekday") self._cache = state.pop("_cache", {}) - def is_anchored(self) -> bool: - warnings.warn( - f"{type(self).__name__}.is_anchored is deprecated and will be removed " - f"in a future version, please use \'obj.n == 1 " - f"and obj.weekday is not None\' instead.", - FutureWarning, - stacklevel=find_stack_level(), - ) - return self.n == 1 and self.weekday is not None - @apply_wraps def _apply(self, other): if self.weekday is None: @@ -3640,17 +3572,6 @@ cdef class FY5253Mixin(SingleConstructorOffset): self.weekday = state.pop("weekday") self.variation = state.pop("variation") - def is_anchored(self) -> bool: - warnings.warn( - f"{type(self).__name__}.is_anchored is deprecated and will be removed " - f"in a future version, please use \'obj.n == 1\' instead.", - FutureWarning, - stacklevel=find_stack_level(), - ) - return ( - self.n == 1 and self.startingMonth is not None and self.weekday is not None - ) - # -------------------------------------------------------------------- # Name-related methods diff --git a/pandas/tests/tseries/offsets/test_business_quarter.py b/pandas/tests/tseries/offsets/test_business_quarter.py index 6d7a115054b7f..3e87ab3e6d397 100644 --- a/pandas/tests/tseries/offsets/test_business_quarter.py +++ b/pandas/tests/tseries/offsets/test_business_quarter.py @@ -9,7 +9,6 @@ import pytest -import pandas._testing as tm from pandas.tests.tseries.offsets.common import ( assert_is_on_offset, assert_offset_equal, @@ -54,14 +53,6 @@ def test_repr(self): expected = "" assert repr(BQuarterBegin(startingMonth=1)) == expected - def test_is_anchored(self): - msg = "BQuarterBegin.is_anchored is deprecated " - - with tm.assert_produces_warning(FutureWarning, match=msg): - assert BQuarterBegin(startingMonth=1).is_anchored() - assert BQuarterBegin().is_anchored() - assert not BQuarterBegin(2, startingMonth=1).is_anchored() - def test_offset_corner_case(self): # corner offset = BQuarterBegin(n=-1, startingMonth=1) @@ -180,14 +171,6 @@ def test_repr(self): expected = "" assert repr(BQuarterEnd(startingMonth=1)) == expected - def test_is_anchored(self): - msg = "BQuarterEnd.is_anchored is deprecated " - - with tm.assert_produces_warning(FutureWarning, match=msg): - assert BQuarterEnd(startingMonth=1).is_anchored() - assert BQuarterEnd().is_anchored() - assert not BQuarterEnd(2, startingMonth=1).is_anchored() - def test_offset_corner_case(self): # corner offset = BQuarterEnd(n=-1, startingMonth=1) diff --git a/pandas/tests/tseries/offsets/test_fiscal.py b/pandas/tests/tseries/offsets/test_fiscal.py index 824e66a1ddef1..208f8f550086a 100644 --- a/pandas/tests/tseries/offsets/test_fiscal.py +++ b/pandas/tests/tseries/offsets/test_fiscal.py @@ -7,7 +7,6 @@ import pytest from pandas import Timestamp -import pandas._testing as tm from pandas.tests.tseries.offsets.common import ( WeekDay, assert_is_on_offset, @@ -295,20 +294,6 @@ def test_apply(self): class TestFY5253LastOfMonthQuarter: - def test_is_anchored(self): - msg = "FY5253Quarter.is_anchored is deprecated " - - with tm.assert_produces_warning(FutureWarning, match=msg): - assert makeFY5253LastOfMonthQuarter( - startingMonth=1, weekday=WeekDay.SAT, qtr_with_extra_week=4 - ).is_anchored() - assert makeFY5253LastOfMonthQuarter( - weekday=WeekDay.SAT, startingMonth=3, qtr_with_extra_week=4 - ).is_anchored() - assert not makeFY5253LastOfMonthQuarter( - 2, startingMonth=1, weekday=WeekDay.SAT, qtr_with_extra_week=4 - ).is_anchored() - def test_equality(self): assert makeFY5253LastOfMonthQuarter( startingMonth=1, weekday=WeekDay.SAT, qtr_with_extra_week=4 diff --git a/pandas/tests/tseries/offsets/test_offsets.py b/pandas/tests/tseries/offsets/test_offsets.py index 72eff4b6ee479..cab9df710ed99 100644 --- a/pandas/tests/tseries/offsets/test_offsets.py +++ b/pandas/tests/tseries/offsets/test_offsets.py @@ -624,13 +624,6 @@ def test_constructor(self, kwd, request): def test_default_constructor(self, dt): assert (dt + DateOffset(2)) == datetime(2008, 1, 4) - def test_is_anchored(self): - msg = "DateOffset.is_anchored is deprecated " - - with tm.assert_produces_warning(FutureWarning, match=msg): - assert not DateOffset(2).is_anchored() - assert DateOffset(1).is_anchored() - def test_copy(self): assert DateOffset(months=2).copy() == DateOffset(months=2) assert DateOffset(milliseconds=1).copy() == DateOffset(milliseconds=1) diff --git a/pandas/tests/tseries/offsets/test_quarter.py b/pandas/tests/tseries/offsets/test_quarter.py index 5fd3ba0a5fb87..d3872b7ce9537 100644 --- a/pandas/tests/tseries/offsets/test_quarter.py +++ b/pandas/tests/tseries/offsets/test_quarter.py @@ -9,7 +9,6 @@ import pytest -import pandas._testing as tm from pandas.tests.tseries.offsets.common import ( assert_is_on_offset, assert_offset_equal, @@ -53,14 +52,6 @@ def test_repr(self): expected = "" assert repr(QuarterBegin(startingMonth=1)) == expected - def test_is_anchored(self): - msg = "QuarterBegin.is_anchored is deprecated " - - with tm.assert_produces_warning(FutureWarning, match=msg): - assert QuarterBegin(startingMonth=1).is_anchored() - assert QuarterBegin().is_anchored() - assert not QuarterBegin(2, startingMonth=1).is_anchored() - def test_offset_corner_case(self): # corner offset = QuarterBegin(n=-1, startingMonth=1) @@ -164,14 +155,6 @@ def test_repr(self): expected = "" assert repr(QuarterEnd(startingMonth=1)) == expected - def test_is_anchored(self): - msg = "QuarterEnd.is_anchored is deprecated " - - with tm.assert_produces_warning(FutureWarning, match=msg): - assert QuarterEnd(startingMonth=1).is_anchored() - assert QuarterEnd().is_anchored() - assert not QuarterEnd(2, startingMonth=1).is_anchored() - def test_offset_corner_case(self): # corner offset = QuarterEnd(n=-1, startingMonth=1) diff --git a/pandas/tests/tseries/offsets/test_ticks.py b/pandas/tests/tseries/offsets/test_ticks.py index 399b7038d3426..07e434e883c04 100644 --- a/pandas/tests/tseries/offsets/test_ticks.py +++ b/pandas/tests/tseries/offsets/test_ticks.py @@ -337,14 +337,6 @@ def test_tick_equalities(cls): assert cls() == cls(1) -@pytest.mark.parametrize("cls", tick_classes) -def test_tick_offset(cls): - msg = f"{cls.__name__}.is_anchored is deprecated " - - with tm.assert_produces_warning(FutureWarning, match=msg): - assert not cls().is_anchored() - - @pytest.mark.parametrize("cls", tick_classes) def test_compare_ticks(cls): three = cls(3) diff --git a/pandas/tests/tseries/offsets/test_week.py b/pandas/tests/tseries/offsets/test_week.py index 0cd6f769769ae..f9a8755dc6336 100644 --- a/pandas/tests/tseries/offsets/test_week.py +++ b/pandas/tests/tseries/offsets/test_week.py @@ -21,7 +21,6 @@ WeekOfMonth, ) -import pandas._testing as tm from pandas.tests.tseries.offsets.common import ( WeekDay, assert_is_on_offset, @@ -42,15 +41,6 @@ def test_corner(self): with pytest.raises(ValueError, match="Day must be"): Week(weekday=-1) - def test_is_anchored(self): - msg = "Week.is_anchored is deprecated " - - with tm.assert_produces_warning(FutureWarning, match=msg): - assert Week(weekday=0).is_anchored() - assert not Week().is_anchored() - assert not Week(2, weekday=2).is_anchored() - assert not Week(2).is_anchored() - offset_cases = [] # not business week offset_cases.append(