From 9891a5b19b7ca9c8b779b946c3a3bdbddeb219af Mon Sep 17 00:00:00 2001 From: gfyoung Date: Mon, 19 Jun 2017 01:08:46 -0700 Subject: [PATCH] MAINT: Drop Categorical.order & sort Deprecated back in 0.18.1 xref gh-12882 --- doc/source/whatsnew/v0.21.0.txt | 1 + pandas/core/categorical.py | 31 ------------------------------- pandas/tests/test_categorical.py | 6 ------ 3 files changed, 1 insertion(+), 37 deletions(-) diff --git a/doc/source/whatsnew/v0.21.0.txt b/doc/source/whatsnew/v0.21.0.txt index d6b699abdba2d..45c92717b60f0 100644 --- a/doc/source/whatsnew/v0.21.0.txt +++ b/doc/source/whatsnew/v0.21.0.txt @@ -75,6 +75,7 @@ Removal of prior version deprecations/changes ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - ``pd.read_excel()`` has dropped the ``has_index_names`` parameter (:issue:`10967`) +- ``Categorical`` has dropped the ``.order()`` and ``.sort()`` methods in favor of ``.sort_values()`` (:issue:`12882`) .. _whatsnew_0210.performance: diff --git a/pandas/core/categorical.py b/pandas/core/categorical.py index f58eed74f760e..ce70fb94b6cd4 100644 --- a/pandas/core/categorical.py +++ b/pandas/core/categorical.py @@ -1447,37 +1447,6 @@ def _values_for_rank(self): ) return values - def order(self, inplace=False, ascending=True, na_position='last'): - """ - DEPRECATED: use :meth:`Categorical.sort_values`. That function - is entirely equivalent to this one. - - See Also - -------- - Categorical.sort_values - """ - warn("order is deprecated, use sort_values(...)", FutureWarning, - stacklevel=2) - return self.sort_values(inplace=inplace, ascending=ascending, - na_position=na_position) - - def sort(self, inplace=True, ascending=True, na_position='last', **kwargs): - """ - DEPRECATED: use :meth:`Categorical.sort_values`. That function - is just like this one, except that a new Categorical is returned - by default, so make sure to pass in 'inplace=True' to get - inplace sorting. - - See Also - -------- - Categorical.sort_values - """ - warn("sort is deprecated, use sort_values(...)", FutureWarning, - stacklevel=2) - nv.validate_sort(tuple(), kwargs) - return self.sort_values(inplace=inplace, ascending=ascending, - na_position=na_position) - def ravel(self, order='C'): """ Return a flattened (numpy) array. diff --git a/pandas/tests/test_categorical.py b/pandas/tests/test_categorical.py index 1ffe956b3a607..92177ca07d835 100644 --- a/pandas/tests/test_categorical.py +++ b/pandas/tests/test_categorical.py @@ -3067,12 +3067,6 @@ def test_sort_values(self): c = Categorical(["a", "b", "b", "a"], ordered=False) cat = Series(c.copy()) - # 'order' was deprecated in gh-10726 - # 'sort' was deprecated in gh-12882 - for func in ('order', 'sort'): - with tm.assert_produces_warning(FutureWarning): - getattr(c, func)() - # sort in the categories order expected = Series( Categorical(["a", "a", "b", "b"],