Skip to content

BUG: Index._id #37321

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 22, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions pandas/core/indexes/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ def _outer_indexer(self, left, right):

_typ = "index"
_data: Union[ExtensionArray, np.ndarray]
_id: _Identity
_id: Optional[_Identity] = None
_name: Label = None
# MultiIndex.levels previously allowed setting the index name. We
# don't allow this anymore, and raise if it happens rather than
Expand Down Expand Up @@ -541,10 +541,14 @@ def is_(self, other) -> bool:
--------
Index.identical : Works like ``Index.is_`` but also checks metadata.
"""
try:
return self._id is other._id
except AttributeError:
if self is other:
return True
elif not hasattr(other, "_id"):
return False
elif com.any_none(self._id, other._id):
return False
else:
return self._id is other._id

def _reset_identity(self) -> None:
"""
Expand Down