Skip to content

Commit 17db2a5

Browse files
pepicellostangirala
authored andcommitted
CLN: raise correct error for Panel sort_values (pandas-dev#16532)
1 parent 7954a90 commit 17db2a5

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

pandas/core/generic.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -2366,9 +2366,14 @@ def add_suffix(self, suffix):
23662366
1 A 1 1
23672367
"""
23682368

2369-
def sort_values(self, by, axis=0, ascending=True, inplace=False,
2369+
def sort_values(self, by=None, axis=0, ascending=True, inplace=False,
23702370
kind='quicksort', na_position='last'):
2371-
raise AbstractMethodError(self)
2371+
"""
2372+
NOT IMPLEMENTED: do not call this method, as sorting values is not
2373+
supported for Panel objects and will raise an error.
2374+
"""
2375+
raise NotImplementedError("sort_values has not been implemented "
2376+
"on Panel or Panel4D objects.")
23722377

23732378
_shared_docs['sort_index'] = """
23742379
Sort object by labels (along an axis)

pandas/tests/test_panel.py

+5
Original file line numberDiff line numberDiff line change
@@ -2429,6 +2429,11 @@ def test_all_any_unhandled(self):
24292429
pytest.raises(NotImplementedError, self.panel.all, bool_only=True)
24302430
pytest.raises(NotImplementedError, self.panel.any, bool_only=True)
24312431

2432+
# GH issue 15960
2433+
def test_sort_values(self):
2434+
pytest.raises(NotImplementedError, self.panel.sort_values)
2435+
pytest.raises(NotImplementedError, self.panel.sort_values, 'ItemA')
2436+
24322437

24332438
class TestLongPanel(object):
24342439
"""

pandas/tests/test_panel4d.py

+5
Original file line numberDiff line numberDiff line change
@@ -939,3 +939,8 @@ def test_rename(self):
939939

940940
def test_get_attr(self):
941941
tm.assert_panel_equal(self.panel4d['l1'], self.panel4d.l1)
942+
943+
# GH issue 15960
944+
def test_sort_values(self):
945+
pytest.raises(NotImplementedError, self.panel4d.sort_values)
946+
pytest.raises(NotImplementedError, self.panel4d.sort_values, 'ItemA')

0 commit comments

Comments
 (0)