Skip to content

Commit af5de36

Browse files
author
Jean-Francois Zinque
committed
BUG: Fix MultiIndex intersection with sort=False
1 parent 6daed50 commit af5de36

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
@@ -3324,9 +3324,11 @@ def intersection(self, other, sort=False):
33243324
if self.equals(other):
33253325
return self
33263326

3327-
self_tuples = self._ndarray_values
3328-
other_tuples = other._ndarray_values
3329-
uniq_tuples = set(self_tuples) & set(other_tuples)
3327+
uniq_other = set(other.values)
3328+
seen = set()
3329+
uniq_tuples = [
3330+
x for x in self.values if x in uniq_other and not (x in seen or seen.add(x))
3331+
]
33303332

33313333
if sort is None:
33323334
uniq_tuples = sorted(uniq_tuples)

0 commit comments

Comments
 (0)