-
-
Notifications
You must be signed in to change notification settings - Fork 19.1k
Closed
Labels
Description
Pandas version checks
-
I have checked that this issue has not already been reported.
-
I have confirmed this bug exists on the latest version of pandas.
-
I have confirmed this bug exists on the main branch of pandas.
Reproducible Example
def sort_function(idx: pd.Index) -> pd.Index:
print(f"Called with {idx=}")
return sorted(idx)
df = pd.DataFrame(
{"col": [1, 9, 4]},
index=[1, 3, 2]
)
df.sort_index(key=sort_function)
Issue Description
Result:
Called with idx=Index([1, 3, 2], dtype='int64')
col
1 1
3 9
2 4
Expected Behavior
Must be:
Called with idx=Index([1, 3, 2], dtype='int64')
col
1 1
2 4
3 9
Installed Versions
>>> pd.__version__
'2.1.3'
Zalnd