Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions pandas/core/arrays/interval.py
Original file line number Diff line number Diff line change
Expand Up @@ -619,6 +619,24 @@ def __lt__(self, other):
def __le__(self, other):
return self._cmp_method(other, operator.le)

def argsort(
self,
ascending: bool = True,
kind: str = "quicksort",
na_position: str = "last",
*args,
**kwargs,
) -> np.ndarray:
ascending = nv.validate_argsort_with_ascending(ascending, args, kwargs)

if ascending and kind == "quicksort" and na_position == "last":
return np.lexsort((self.right, self.left))

# TODO: other cases we can use lexsort for? much more performant.
return super().argsort(
ascending=ascending, kind=kind, na_position=na_position, **kwargs
)

def fillna(self, value=None, method=None, limit=None):
"""
Fill NA/NaN values using the specified method.
Expand Down
5 changes: 0 additions & 5 deletions pandas/core/indexes/interval.py
Original file line number Diff line number Diff line change
Expand Up @@ -957,11 +957,6 @@ def _format_space(self) -> str:
space = " " * (len(type(self).__name__) + 1)
return f"\n{space}"

# --------------------------------------------------------------------

def argsort(self, *args, **kwargs) -> np.ndarray:
return np.lexsort((self.right, self.left))

# --------------------------------------------------------------------
# Set Operations

Expand Down