Skip to content

Commit d0e771b

Browse files
authored
DEPR: remove Categorical.to_list (pandas-dev#58000)
1 parent ded256d commit d0e771b

File tree

3 files changed

+1
-20
lines changed

3 files changed

+1
-20
lines changed

doc/source/whatsnew/v3.0.0.rst

+1
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@ Removal of prior version deprecations/changes
211211
- Enforced deprecation of strings ``T``, ``L``, ``U``, and ``N`` denoting units in :class:`Timedelta` (:issue:`57627`)
212212
- 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`)
213213
- Enforced deprecation of values "pad", "ffill", "bfill", and "backfill" for :meth:`Series.interpolate` and :meth:`DataFrame.interpolate` (:issue:`57869`)
214+
- Enforced deprecation removing :meth:`Categorical.to_list`, use ``obj.tolist()`` instead (:issue:`51254`)
214215
- Enforced silent-downcasting deprecation for :ref:`all relevant methods <whatsnew_220.silent_downcasting>` (:issue:`54710`)
215216
- In :meth:`DataFrame.stack`, the default value of ``future_stack`` is now ``True``; specifying ``False`` will raise a ``FutureWarning`` (:issue:`55448`)
216217
- 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`)

pandas/core/arrays/categorical.py

-13
Original file line numberDiff line numberDiff line change
@@ -626,19 +626,6 @@ def astype(self, dtype: AstypeArg, copy: bool = True) -> ArrayLike:
626626

627627
return result
628628

629-
def to_list(self) -> list:
630-
"""
631-
Alias for tolist.
632-
"""
633-
# GH#51254
634-
warnings.warn(
635-
"Categorical.to_list is deprecated and will be removed in a future "
636-
"version. Use obj.tolist() instead",
637-
FutureWarning,
638-
stacklevel=find_stack_level(),
639-
)
640-
return self.tolist()
641-
642629
@classmethod
643630
def _from_inferred_categories(
644631
cls, inferred_categories, inferred_codes, dtype, true_values=None

pandas/tests/arrays/categorical/test_api.py

-7
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,6 @@
1818

1919

2020
class TestCategoricalAPI:
21-
def test_to_list_deprecated(self):
22-
# GH#51254
23-
cat1 = Categorical(list("acb"), ordered=False)
24-
msg = "Categorical.to_list is deprecated and will be removed"
25-
with tm.assert_produces_warning(FutureWarning, match=msg):
26-
cat1.to_list()
27-
2821
def test_ordered_api(self):
2922
# GH 9347
3023
cat1 = Categorical(list("acb"), ordered=False)

0 commit comments

Comments
 (0)