Skip to content

Commit 0a265b6

Browse files
topper-123Kevin D Smith
authored and
Kevin D Smith
committed
BUG: Index._id (pandas-dev#37321)
1 parent 189bef1 commit 0a265b6

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

pandas/core/indexes/base.py

+8-4
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ def _outer_indexer(self, left, right):
220220

221221
_typ = "index"
222222
_data: Union[ExtensionArray, np.ndarray]
223-
_id: _Identity
223+
_id: Optional[_Identity] = None
224224
_name: Label = None
225225
# MultiIndex.levels previously allowed setting the index name. We
226226
# don't allow this anymore, and raise if it happens rather than
@@ -541,10 +541,14 @@ def is_(self, other) -> bool:
541541
--------
542542
Index.identical : Works like ``Index.is_`` but also checks metadata.
543543
"""
544-
try:
545-
return self._id is other._id
546-
except AttributeError:
544+
if self is other:
545+
return True
546+
elif not hasattr(other, "_id"):
547547
return False
548+
elif com.any_none(self._id, other._id):
549+
return False
550+
else:
551+
return self._id is other._id
548552

549553
def _reset_identity(self) -> None:
550554
"""

0 commit comments

Comments
 (0)