Skip to content

DEPR: remove Categorical.to_list #58000

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/source/whatsnew/v3.0.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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 <whatsnew_220.silent_downcasting>` (: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`)
Expand Down
13 changes: 0 additions & 13 deletions pandas/core/arrays/categorical.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 0 additions & 7 deletions pandas/tests/arrays/categorical/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down