Skip to content

Commit

Permalink
CLN: Remove Index.sort (#59283)
Browse files Browse the repository at this point in the history
  • Loading branch information
mroeschke authored Jul 23, 2024
1 parent e191a06 commit 1fa5025
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 13 deletions.
1 change: 1 addition & 0 deletions doc/source/whatsnew/v3.0.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ Other API changes
- All classes inheriting from builtin ``tuple`` (including types created with :func:`collections.namedtuple`) are now hashed and compared as builtin ``tuple`` during indexing operations (:issue:`57922`)
- Made ``dtype`` a required argument in :meth:`ExtensionArray._from_sequence_of_strings` (:issue:`56519`)
- Passing a :class:`Series` input to :func:`json_normalize` will now retain the :class:`Series` :class:`Index`, previously output had a new :class:`RangeIndex` (:issue:`51452`)
- Removed :meth:`Index.sort` which always raised a ``TypeError``. This attribute is not defined and will raise an ``AttributeError`` (:issue:`59283`)
- Updated :meth:`DataFrame.to_excel` so that the output spreadsheet has no styling. Custom styling can still be done using :meth:`Styler.to_excel` (:issue:`54154`)
- pickle and HDF (``.h5``) files created with Python 2 are no longer explicitly supported (:issue:`57387`)
- pickled objects from pandas version less than ``1.0.0`` are no longer supported (:issue:`57155`)
Expand Down
7 changes: 0 additions & 7 deletions pandas/core/indexes/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -5785,13 +5785,6 @@ def sort_values(
else:
return sorted_index

@final
def sort(self, *args, **kwargs):
"""
Use sort_values instead.
"""
raise TypeError("cannot sort an Index object in-place, use sort_values instead")

def shift(self, periods: int = 1, freq=None) -> Self:
"""
Shift index by desired number of time frequency increments.
Expand Down
6 changes: 0 additions & 6 deletions pandas/tests/indexes/test_any_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,6 @@ def test_boolean_context_compat(index):
bool(index)


def test_sort(index):
msg = "cannot sort an Index object in-place, use sort_values instead"
with pytest.raises(TypeError, match=msg):
index.sort()


def test_hash_error(index):
with pytest.raises(TypeError, match=f"unhashable type: '{type(index).__name__}'"):
hash(index)
Expand Down

0 comments on commit 1fa5025

Please sign in to comment.