Skip to content

Commit 391548e

Browse files
author
Jean-Francois Zinque
committed
BUG: Fix MultiIndex intersection with sort=False
1 parent ffa3f94 commit 391548e

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

pandas/core/indexes/multi.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -3314,9 +3314,11 @@ def intersection(self, other, sort=False):
33143314
if self.equals(other):
33153315
return self
33163316

3317-
self_tuples = self._ndarray_values
3318-
other_tuples = other._ndarray_values
3319-
uniq_tuples = set(self_tuples) & set(other_tuples)
3317+
uniq_other = set(other.values)
3318+
seen = set()
3319+
uniq_tuples = [
3320+
x for x in self.values if x in uniq_other and not (x in seen or seen.add(x))
3321+
]
33203322

33213323
if sort is None:
33223324
uniq_tuples = sorted(uniq_tuples)

0 commit comments

Comments
 (0)