Skip to content

Commit fd4d913

Browse files
committed
CLN: Remove Index.sort
1 parent 7a4a7bf commit fd4d913

File tree

3 files changed

+1
-13
lines changed

3 files changed

+1
-13
lines changed

doc/source/whatsnew/v3.0.0.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,7 @@ Other API changes
237237
- pickle and HDF (``.h5``) files created with Python 2 are no longer explicitly supported (:issue:`57387`)
238238
- pickled objects from pandas version less than ``1.0.0`` are no longer supported (:issue:`57155`)
239239
- when comparing the indexes in :func:`testing.assert_series_equal`, check_exact defaults to True if an :class:`Index` is of integer dtypes. (:issue:`57386`)
240+
- Removed :meth:`Index.sort` which always raised a ``TypeError``. This attribute is not defined and will raise an ``AttributeError`` (:issue:`?`)
240241

241242
.. ---------------------------------------------------------------------------
242243
.. _whatsnew_300.deprecations:

pandas/core/indexes/base.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5779,13 +5779,6 @@ def sort_values(
57795779
else:
57805780
return sorted_index
57815781

5782-
@final
5783-
def sort(self, *args, **kwargs):
5784-
"""
5785-
Use sort_values instead.
5786-
"""
5787-
raise TypeError("cannot sort an Index object in-place, use sort_values instead")
5788-
57895782
def shift(self, periods: int = 1, freq=None) -> Self:
57905783
"""
57915784
Shift index by desired number of time frequency increments.

pandas/tests/indexes/test_any_index.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,6 @@ def test_boolean_context_compat(index):
2222
bool(index)
2323

2424

25-
def test_sort(index):
26-
msg = "cannot sort an Index object in-place, use sort_values instead"
27-
with pytest.raises(TypeError, match=msg):
28-
index.sort()
29-
30-
3125
def test_hash_error(index):
3226
with pytest.raises(TypeError, match=f"unhashable type: '{type(index).__name__}'"):
3327
hash(index)

0 commit comments

Comments
 (0)