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 @@ -4455,15 +4455,16 @@ def equals(self, other: object) -> bool:
4455
4455
if not isinstance (other , Index ):
4456
4456
return False
4457
4457
4458
- # If other is a subclass of self and defines its own equals method, we
4459
- # dispatch to the subclass method. For instance for a MultiIndex,
4460
- # a d-level MultiIndex can equal d-tuple Index.
4461
- # Note: All EA-backed Index subclasses override equals
4462
- if (
4463
- isinstance (other , type (self ))
4464
- and type (other ) is not type (self )
4465
- and other .equals is not self .equals
4466
- ):
4458
+ if is_object_dtype (self .dtype ) and not is_object_dtype (other .dtype ):
4459
+ # if other is not object, use other's logic for coercion
4460
+ return other .equals (self )
4461
+
4462
+ if isinstance (other , ABCMultiIndex ):
4463
+ # d-level MultiIndex can equal d-tuple Index
4464
+ return other .equals (self )
4465
+
4466
+ if is_extension_array_dtype (other .dtype ):
4467
+ # All EA-backed Index subclasses override equals
4467
4468
return other .equals (self )
4468
4469
4469
4470
return array_equivalent (self ._values , other ._values )
You can’t perform that action at this time.
0 commit comments