diff --git a/doc/source/whatsnew/v3.0.0.rst b/doc/source/whatsnew/v3.0.0.rst index 4d2381ae1e5e4..f3729fb697bea 100644 --- a/doc/source/whatsnew/v3.0.0.rst +++ b/doc/source/whatsnew/v3.0.0.rst @@ -211,6 +211,7 @@ Removal of prior version deprecations/changes - Enforced deprecation of strings ``T``, ``L``, ``U``, and ``N`` denoting units in :class:`Timedelta` (:issue:`57627`) - Enforced deprecation of the behavior of :func:`concat` when ``len(keys) != len(objs)`` would truncate to the shorter of the two. Now this raises a ``ValueError`` (:issue:`43485`) - Enforced deprecation of values "pad", "ffill", "bfill", and "backfill" for :meth:`Series.interpolate` and :meth:`DataFrame.interpolate` (:issue:`57869`) +- Enforced deprecation removing :meth:`Categorical.to_list`, use ``obj.tolist()`` instead (:issue:`51254`) - 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`) - Iterating over a :class:`.DataFrameGroupBy` or :class:`.SeriesGroupBy` will return tuples of length 1 for the groups when grouping by ``level`` a list of length 1 (:issue:`50064`) diff --git a/pandas/core/arrays/categorical.py b/pandas/core/arrays/categorical.py index 429dc9236cf45..416331a260e9f 100644 --- a/pandas/core/arrays/categorical.py +++ b/pandas/core/arrays/categorical.py @@ -626,19 +626,6 @@ def astype(self, dtype: AstypeArg, copy: bool = True) -> ArrayLike: return result - def to_list(self) -> list: - """ - Alias for tolist. - """ - # GH#51254 - warnings.warn( - "Categorical.to_list is deprecated and will be removed in a future " - "version. Use obj.tolist() instead", - FutureWarning, - stacklevel=find_stack_level(), - ) - return self.tolist() - @classmethod def _from_inferred_categories( cls, inferred_categories, inferred_codes, dtype, true_values=None diff --git a/pandas/tests/arrays/categorical/test_api.py b/pandas/tests/arrays/categorical/test_api.py index cff8afaa17516..2791fd55f54d7 100644 --- a/pandas/tests/arrays/categorical/test_api.py +++ b/pandas/tests/arrays/categorical/test_api.py @@ -18,13 +18,6 @@ class TestCategoricalAPI: - def test_to_list_deprecated(self): - # GH#51254 - cat1 = Categorical(list("acb"), ordered=False) - msg = "Categorical.to_list is deprecated and will be removed" - with tm.assert_produces_warning(FutureWarning, match=msg): - cat1.to_list() - def test_ordered_api(self): # GH 9347 cat1 = Categorical(list("acb"), ordered=False)