Skip to content

Commit

Permalink
CLN: Drop .sortlevel method (pandas-dev#23375)
Browse files Browse the repository at this point in the history
  • Loading branch information
gfyoung authored and Pingviinituutti committed Feb 28, 2019
1 parent 2a91e0b commit 6b621ac
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 78 deletions.
1 change: 1 addition & 0 deletions doc/source/whatsnew/v0.24.0.txt
Original file line number Diff line number Diff line change
Expand Up @@ -951,6 +951,7 @@ Removal of prior version deprecations/changes
- :meth:`DataFrame.consolidate` and :meth:`Series.consolidate` have been removed (:issue:`15501`)
- 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:
Expand Down
36 changes: 1 addition & 35 deletions pandas/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down
29 changes: 1 addition & 28 deletions pandas/core/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
8 changes: 0 additions & 8 deletions pandas/tests/frame/test_sorting.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'))
Expand Down
7 changes: 0 additions & 7 deletions pandas/tests/series/test_sorting.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 6b621ac

Please sign in to comment.