diff --git a/pandas/core/arrays/categorical.py b/pandas/core/arrays/categorical.py index 164dc74836508..48371b7f14b28 100644 --- a/pandas/core/arrays/categorical.py +++ b/pandas/core/arrays/categorical.py @@ -2353,29 +2353,6 @@ def max(self, *, skipna: bool = True, **kwargs): pointer = self._codes.max() return self._wrap_reduction_result(None, pointer) - def mode(self, dropna: bool = True) -> Categorical: - """ - Returns the mode(s) of the Categorical. - - Always returns `Categorical` even if only one value. - - Parameters - ---------- - dropna : bool, default True - Don't consider counts of NaN/NaT. - - Returns - ------- - modes : `Categorical` (sorted) - """ - warn( - "Categorical.mode is deprecated and will be removed in a future version. " - "Use Series.mode instead.", - FutureWarning, - stacklevel=find_stack_level(), - ) - return self._mode(dropna=dropna) - def _mode(self, dropna: bool = True) -> Categorical: codes = self._codes mask = None diff --git a/pandas/tests/arrays/categorical/test_analytics.py b/pandas/tests/arrays/categorical/test_analytics.py index 39590bcc6636e..e9f4be11ee4b7 100644 --- a/pandas/tests/arrays/categorical/test_analytics.py +++ b/pandas/tests/arrays/categorical/test_analytics.py @@ -158,10 +158,8 @@ def test_numpy_min_max_axis_equals_none(self, method, expected): ], ) def test_mode(self, values, categories, exp_mode): - s = Categorical(values, categories=categories, ordered=True) - msg = "Use Series.mode instead" - with tm.assert_produces_warning(FutureWarning, match=msg): - res = s.mode() + cat = Categorical(values, categories=categories, ordered=True) + res = Series(cat).mode()._values exp = Categorical(exp_mode, categories=categories, ordered=True) tm.assert_categorical_equal(res, exp) diff --git a/pandas/tests/test_algos.py b/pandas/tests/test_algos.py index b6891dac9034b..a6b765117f616 100644 --- a/pandas/tests/test_algos.py +++ b/pandas/tests/test_algos.py @@ -2296,21 +2296,17 @@ def test_uint64_overflow(self): def test_categorical(self): c = Categorical([1, 2]) exp = c - msg = "Categorical.mode is deprecated" - with tm.assert_produces_warning(FutureWarning, match=msg): - res = c.mode() + res = Series(c).mode()._values tm.assert_categorical_equal(res, exp) c = Categorical([1, "a", "a"]) exp = Categorical(["a"], categories=[1, "a"]) - with tm.assert_produces_warning(FutureWarning, match=msg): - res = c.mode() + res = Series(c).mode()._values tm.assert_categorical_equal(res, exp) c = Categorical([1, 1, 2, 3, 3]) exp = Categorical([1, 3], categories=[1, 2, 3]) - with tm.assert_produces_warning(FutureWarning, match=msg): - res = c.mode() + res = Series(c).mode()._values tm.assert_categorical_equal(res, exp) def test_index(self):