Skip to content

Commit 5266143

Browse files
authored
CLN: Move monotonic check to safe_sort_index (#47573)
1 parent 6792f5c commit 5266143

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

pandas/core/indexes/api.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ def _get_combined_index(
157157
index = union_indexes(indexes, sort=False)
158158
index = ensure_index(index)
159159

160-
if sort and not index.is_monotonic_increasing:
160+
if sort:
161161
index = safe_sort_index(index)
162162
# GH 29879
163163
if copy:
@@ -180,6 +180,9 @@ def safe_sort_index(index: Index) -> Index:
180180
-------
181181
Index
182182
"""
183+
if index.is_monotonic_increasing:
184+
return index
185+
183186
try:
184187
array_sorted = safe_sort(index)
185188
except TypeError:

0 commit comments

Comments
 (0)