Skip to content

Commit 2c9fb60

Browse files
jbrockmendelKevin D Smith
authored and
Kevin D Smith
committed
REF: move IntervalIndex.equals up to ExtensionIndex.equals (pandas-dev#37561)
1 parent 96bdb07 commit 2c9fb60

File tree

2 files changed

+11
-12
lines changed

2 files changed

+11
-12
lines changed

pandas/core/indexes/extension.py

+11
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,17 @@ def astype(self, dtype, copy=True):
283283
def _isnan(self) -> np.ndarray:
284284
return self._data.isna()
285285

286+
@doc(Index.equals)
287+
def equals(self, other) -> bool:
288+
# Dispatch to the ExtensionArray's .equals method.
289+
if self.is_(other):
290+
return True
291+
292+
if not isinstance(other, type(self)):
293+
return False
294+
295+
return self._data.equals(other._data)
296+
286297

287298
class NDArrayBackedExtensionIndex(ExtensionIndex):
288299
"""

pandas/core/indexes/interval.py

-12
Original file line numberDiff line numberDiff line change
@@ -970,18 +970,6 @@ def _format_space(self) -> str:
970970
def argsort(self, *args, **kwargs) -> np.ndarray:
971971
return np.lexsort((self.right, self.left))
972972

973-
def equals(self, other: object) -> bool:
974-
"""
975-
Determines if two IntervalIndex objects contain the same elements.
976-
"""
977-
if self.is_(other):
978-
return True
979-
980-
if not isinstance(other, IntervalIndex):
981-
return False
982-
983-
return self._data.equals(other._data)
984-
985973
# --------------------------------------------------------------------
986974
# Set Operations
987975

0 commit comments

Comments
 (0)