File tree 1 file changed +10
-9
lines changed
1 file changed +10
-9
lines changed Original file line number Diff line number Diff line change @@ -4442,15 +4442,16 @@ def equals(self, other: object) -> bool:
4442
4442
if not isinstance (other , Index ):
4443
4443
return False
4444
4444
4445
- # If other is a subclass of self and defines its own equals method, we
4446
- # dispatch to the subclass method. For instance for a MultiIndex,
4447
- # a d-level MultiIndex can equal d-tuple Index.
4448
- # Note: All EA-backed Index subclasses override equals
4449
- if (
4450
- isinstance (other , type (self ))
4451
- and type (other ) is not type (self )
4452
- and other .equals is not self .equals
4453
- ):
4445
+ if is_object_dtype (self .dtype ) and not is_object_dtype (other .dtype ):
4446
+ # if other is not object, use other's logic for coercion
4447
+ return other .equals (self )
4448
+
4449
+ if isinstance (other , ABCMultiIndex ):
4450
+ # d-level MultiIndex can equal d-tuple Index
4451
+ return other .equals (self )
4452
+
4453
+ if is_extension_array_dtype (other .dtype ):
4454
+ # All EA-backed Index subclasses override equals
4454
4455
return other .equals (self )
4455
4456
4456
4457
return array_equivalent (self ._values , other ._values )
You can’t perform that action at this time.
0 commit comments