diff --git a/pandas/core/generic.py b/pandas/core/generic.py index e541f1532d0a0..98999ec267c82 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -2366,9 +2366,14 @@ def add_suffix(self, suffix): 1 A 1 1 """ - def sort_values(self, by, axis=0, ascending=True, inplace=False, + def sort_values(self, by=None, axis=0, ascending=True, inplace=False, kind='quicksort', na_position='last'): - raise AbstractMethodError(self) + """ + NOT IMPLEMENTED: do not call this method, as sorting values is not + supported for Panel objects and will raise an error. + """ + raise NotImplementedError("sort_values has not been implemented " + "on Panel or Panel4D objects.") _shared_docs['sort_index'] = """ Sort object by labels (along an axis) diff --git a/pandas/tests/test_panel.py b/pandas/tests/test_panel.py index 3243b69a25acd..e19e42e062932 100644 --- a/pandas/tests/test_panel.py +++ b/pandas/tests/test_panel.py @@ -2429,6 +2429,11 @@ def test_all_any_unhandled(self): pytest.raises(NotImplementedError, self.panel.all, bool_only=True) pytest.raises(NotImplementedError, self.panel.any, bool_only=True) + # GH issue 15960 + def test_sort_values(self): + pytest.raises(NotImplementedError, self.panel.sort_values) + pytest.raises(NotImplementedError, self.panel.sort_values, 'ItemA') + class TestLongPanel(object): """ diff --git a/pandas/tests/test_panel4d.py b/pandas/tests/test_panel4d.py index 96f02d63712fc..e1995316e7b7c 100644 --- a/pandas/tests/test_panel4d.py +++ b/pandas/tests/test_panel4d.py @@ -939,3 +939,8 @@ def test_rename(self): def test_get_attr(self): tm.assert_panel_equal(self.panel4d['l1'], self.panel4d.l1) + + # GH issue 15960 + def test_sort_values(self): + pytest.raises(NotImplementedError, self.panel4d.sort_values) + pytest.raises(NotImplementedError, self.panel4d.sort_values, 'ItemA')