Skip to content

Commit b324c38

Browse files
author
Jean-Francois Zinque
committed
BUG: Fix MultiIndex intersection with sort=False
1 parent 8614bc7 commit b324c38

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
@@ -3229,9 +3229,11 @@ def intersection(self, other, sort=False):
32293229
if self.equals(other):
32303230
return self
32313231

3232-
self_tuples = self._ndarray_values
3233-
other_tuples = other._ndarray_values
3234-
uniq_tuples = set(self_tuples) & set(other_tuples)
3232+
uniq_other = set(other.values)
3233+
seen = set()
3234+
uniq_tuples = [
3235+
x for x in self.values if x in uniq_other and not (x in seen or seen.add(x))
3236+
]
32353237

32363238
if sort is None:
32373239
uniq_tuples = sorted(uniq_tuples)

0 commit comments

Comments
 (0)