Skip to content

Commit 8b5e3d6

Browse files
gfyoungjreback
authored andcommitted
MAINT: Drop Categorical.order & sort (pandas-dev#16728)
Deprecated back in 0.18.1 xref pandas-devgh-12882
1 parent 09d8c22 commit 8b5e3d6

File tree

3 files changed

+1
-37
lines changed

3 files changed

+1
-37
lines changed

doc/source/whatsnew/v0.21.0.txt

+1
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ Removal of prior version deprecations/changes
7575
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
7676

7777
- ``pd.read_excel()`` has dropped the ``has_index_names`` parameter (:issue:`10967`)
78+
- ``Categorical`` has dropped the ``.order()`` and ``.sort()`` methods in favor of ``.sort_values()`` (:issue:`12882`)
7879

7980

8081
.. _whatsnew_0210.performance:

pandas/core/categorical.py

-31
Original file line numberDiff line numberDiff line change
@@ -1447,37 +1447,6 @@ def _values_for_rank(self):
14471447
)
14481448
return values
14491449

1450-
def order(self, inplace=False, ascending=True, na_position='last'):
1451-
"""
1452-
DEPRECATED: use :meth:`Categorical.sort_values`. That function
1453-
is entirely equivalent to this one.
1454-
1455-
See Also
1456-
--------
1457-
Categorical.sort_values
1458-
"""
1459-
warn("order is deprecated, use sort_values(...)", FutureWarning,
1460-
stacklevel=2)
1461-
return self.sort_values(inplace=inplace, ascending=ascending,
1462-
na_position=na_position)
1463-
1464-
def sort(self, inplace=True, ascending=True, na_position='last', **kwargs):
1465-
"""
1466-
DEPRECATED: use :meth:`Categorical.sort_values`. That function
1467-
is just like this one, except that a new Categorical is returned
1468-
by default, so make sure to pass in 'inplace=True' to get
1469-
inplace sorting.
1470-
1471-
See Also
1472-
--------
1473-
Categorical.sort_values
1474-
"""
1475-
warn("sort is deprecated, use sort_values(...)", FutureWarning,
1476-
stacklevel=2)
1477-
nv.validate_sort(tuple(), kwargs)
1478-
return self.sort_values(inplace=inplace, ascending=ascending,
1479-
na_position=na_position)
1480-
14811450
def ravel(self, order='C'):
14821451
""" Return a flattened (numpy) array.
14831452

pandas/tests/test_categorical.py

-6
Original file line numberDiff line numberDiff line change
@@ -3067,12 +3067,6 @@ def test_sort_values(self):
30673067
c = Categorical(["a", "b", "b", "a"], ordered=False)
30683068
cat = Series(c.copy())
30693069

3070-
# 'order' was deprecated in gh-10726
3071-
# 'sort' was deprecated in gh-12882
3072-
for func in ('order', 'sort'):
3073-
with tm.assert_produces_warning(FutureWarning):
3074-
getattr(c, func)()
3075-
30763070
# sort in the categories order
30773071
expected = Series(
30783072
Categorical(["a", "a", "b", "b"],

0 commit comments

Comments
 (0)