Skip to content

PERF: MultiIndex.equals #43589

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 3 commits into from
Sep 16, 2021
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions doc/source/whatsnew/v1.3.4.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ including other versions of pandas.
Fixed regressions
~~~~~~~~~~~~~~~~~
- Fixed regression in :meth:`merge` with integer and ``NaN`` keys failing with ``outer`` merge (:issue:`43550`)
- Fixed performance regression in :meth:`MultiIndex.equals` (:issue:`43549`)
-

.. ---------------------------------------------------------------------------
Expand Down
9 changes: 7 additions & 2 deletions pandas/core/indexes/multi.py
Original file line number Diff line number Diff line change
Expand Up @@ -3544,8 +3544,13 @@ def equals(self, other: object) -> bool:
if len(self_values) == 0 and len(other_values) == 0:
continue

if not array_equivalent(self_values, other_values):
return False
if not isinstance(self_values, np.ndarray):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe should do this check in array_equivalent?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

at some point probably; need to check if other usages will be affected by the semantics of EA.equals

# i.e. ExtensionArray
if not self_values.equals(other_values):
return False
else:
if not array_equivalent(self_values, other_values):
return False

return True

Expand Down