diff --git a/doc/source/whatsnew/v0.24.0.txt b/doc/source/whatsnew/v0.24.0.txt index 768868d585721..89c9dc17f5311 100644 --- a/doc/source/whatsnew/v0.24.0.txt +++ b/doc/source/whatsnew/v0.24.0.txt @@ -947,6 +947,7 @@ Removal of prior version deprecations/changes - :meth:`TimedeltaIndex.searchsorted`, :meth:`DatetimeIndex.searchsorted`, and :meth:`PeriodIndex.searchsorted` have renamed the ``key`` argument to ``value`` (:issue:`14645`) - Removal of the previously deprecated module ``pandas.json`` (:issue:`19944`) - :meth:`SparseArray.get_values` and :meth:`SparseArray.to_dense` have dropped the ``fill`` parameter (:issue:`14686`) +- :meth:`DataFrame.sortlevel` and :meth:`Series.sortlevel` have been removed (:issue:`15099`) - :meth:`SparseSeries.to_dense` has dropped the ``sparse_only`` parameter (:issue:`14686`) .. _whatsnew_0240.performance: diff --git a/pandas/core/frame.py b/pandas/core/frame.py index 61721ce4c82e7..a58d34574d28d 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -361,7 +361,7 @@ def _constructor(self): _constructor_sliced = Series _deprecations = NDFrame._deprecations | frozenset( - ['sortlevel', 'get_value', 'set_value', 'from_csv', 'from_items']) + ['get_value', 'set_value', 'from_csv', 'from_items']) _accessors = set() @property @@ -4645,40 +4645,6 @@ def sort_index(self, axis=0, level=None, ascending=True, inplace=False, else: return self._constructor(new_data).__finalize__(self) - def sortlevel(self, level=0, axis=0, ascending=True, inplace=False, - sort_remaining=True): - """Sort multilevel index by chosen axis and primary level. Data will be - lexicographically sorted by the chosen level followed by the other - levels (in order). - - .. deprecated:: 0.20.0 - Use :meth:`DataFrame.sort_index` - - - Parameters - ---------- - level : int - axis : {0 or 'index', 1 or 'columns'}, default 0 - ascending : boolean, default True - inplace : boolean, default False - Sort the DataFrame without creating a new instance - sort_remaining : boolean, default True - Sort by the other levels too. - - Returns - ------- - sorted : DataFrame - - See Also - -------- - DataFrame.sort_index(level=...) - - """ - warnings.warn("sortlevel is deprecated, use sort_index(level= ...)", - FutureWarning, stacklevel=2) - return self.sort_index(level=level, axis=axis, ascending=ascending, - inplace=inplace, sort_remaining=sort_remaining) - def nlargest(self, n, columns, keep='first'): """ Return the first `n` rows ordered by `columns` in descending order. diff --git a/pandas/core/series.py b/pandas/core/series.py index d03a88ea78f6f..64d2e803dc8e1 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -145,7 +145,7 @@ class Series(base.IndexOpsMixin, generic.NDFrame): _metadata = ['name'] _accessors = {'dt', 'cat', 'str', 'sparse'} _deprecations = generic.NDFrame._deprecations | frozenset( - ['asobject', 'sortlevel', 'reshape', 'get_value', 'set_value', + ['asobject', 'reshape', 'get_value', 'set_value', 'from_csv', 'valid']) # Override cache_readonly bc Series is mutable @@ -2962,33 +2962,6 @@ def nsmallest(self, n=5, keep='first'): """ return algorithms.SelectNSeries(self, n=n, keep=keep).nsmallest() - def sortlevel(self, level=0, ascending=True, sort_remaining=True): - """Sort Series with MultiIndex by chosen level. Data will be - lexicographically sorted by the chosen level followed by the other - levels (in order), - - .. deprecated:: 0.20.0 - Use :meth:`Series.sort_index` - - Parameters - ---------- - level : int or level name, default None - ascending : bool, default True - - Returns - ------- - sorted : Series - - See Also - -------- - Series.sort_index(level=...) - - """ - warnings.warn("sortlevel is deprecated, use sort_index(level=...)", - FutureWarning, stacklevel=2) - return self.sort_index(level=level, ascending=ascending, - sort_remaining=sort_remaining) - def swaplevel(self, i=-2, j=-1, copy=True): """ Swap levels i and j in a MultiIndex diff --git a/pandas/tests/frame/test_sorting.py b/pandas/tests/frame/test_sorting.py index 41b11d9c15f35..b99e8983b5ba1 100644 --- a/pandas/tests/frame/test_sorting.py +++ b/pandas/tests/frame/test_sorting.py @@ -21,14 +21,6 @@ class TestDataFrameSorting(TestData): - def test_sort(self): - frame = DataFrame(np.arange(16).reshape(4, 4), index=[1, 2, 3, 4], - columns=['A', 'B', 'C', 'D']) - - # see gh-9816 - with tm.assert_produces_warning(FutureWarning): - frame.sortlevel() - def test_sort_values(self): frame = DataFrame([[1, 1, 2], [3, 1, 0], [4, 5, 6]], index=[1, 2, 3], columns=list('ABC')) diff --git a/pandas/tests/series/test_sorting.py b/pandas/tests/series/test_sorting.py index 13e0d1b12c372..b97a8b762da88 100644 --- a/pandas/tests/series/test_sorting.py +++ b/pandas/tests/series/test_sorting.py @@ -15,13 +15,6 @@ class TestSeriesSorting(TestData): - def test_sortlevel_deprecated(self): - ts = self.ts.copy() - - # see gh-9816 - with tm.assert_produces_warning(FutureWarning): - ts.sortlevel() - def test_sort_values(self): # check indexes are reordered corresponding with the values