Skip to content

Commit 7f4079c

Browse files
BUG: Fix Index.equals with string vs object dtype (pandas-dev#61099)
1 parent aba9ff7 commit 7f4079c

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

pandas/core/indexes/base.py

+5-6
Original file line numberDiff line numberDiff line change
@@ -5471,12 +5471,11 @@ def equals(self, other: Any) -> bool:
54715471
# quickly return if the lengths are different
54725472
return False
54735473

5474-
if (isinstance(self.dtype, StringDtype) or is_object_dtype(self.dtype)) and (
5475-
isinstance(other.dtype, StringDtype) or is_object_dtype(other.dtype)
5476-
):
5477-
return array_equivalent(
5478-
self.astype("object")._values, other.astype("object")._values
5479-
)
5474+
if (
5475+
(isinstance(self.dtype, StringDtype) or is_object_dtype(self.dtype)) and
5476+
(isinstance(other.dtype, StringDtype) or is_object_dtype(other.dtype))
5477+
):
5478+
return array_equivalent(self._values, other._values)
54805479

54815480
if (
54825481
isinstance(self.dtype, StringDtype)

0 commit comments

Comments
 (0)