Skip to content

Commit 05cab15

Browse files
author
Jean-Francois Zinque
committed
BUG: Fix MultiIndex intersection on non-numeric monotonic indexes
1 parent dbfcd24 commit 05cab15

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

pandas/core/indexes/multi.py

+11-6
Original file line numberDiff line numberDiff line change
@@ -3327,14 +3327,19 @@ def intersection(self, other, sort=False):
33273327
lvals = self._ndarray_values
33283328
rvals = other._ndarray_values
33293329

3330+
uniq_tuples = None
33303331
if self.is_monotonic and other.is_monotonic:
3331-
return self._inner_indexer(lvals, rvals)[0]
3332+
try:
3333+
uniq_tuples = self._inner_indexer(lvals, rvals)[0]
3334+
except TypeError:
3335+
pass
33323336

3333-
other_uniq = set(rvals)
3334-
seen = set()
3335-
uniq_tuples = [
3336-
x for x in lvals if x in other_uniq and not (x in seen or seen.add(x))
3337-
]
3337+
if uniq_tuples is None:
3338+
other_uniq = set(rvals)
3339+
seen = set()
3340+
uniq_tuples = [
3341+
x for x in lvals if x in other_uniq and not (x in seen or seen.add(x))
3342+
]
33383343

33393344
if sort is None:
33403345
uniq_tuples = sorted(uniq_tuples)

0 commit comments

Comments
 (0)