Skip to content

Commit a0d3a3d

Browse files
author
Jean-Francois Zinque
committed
BUG: Fix MultiIndex intersection on non-numeric monotonic indexes
1 parent 8858e78 commit a0d3a3d

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
@@ -3317,14 +3317,19 @@ def intersection(self, other, sort=False):
33173317
lvals = self._ndarray_values
33183318
rvals = other._ndarray_values
33193319

3320+
uniq_tuples = None
33203321
if self.is_monotonic and other.is_monotonic:
3321-
return self._inner_indexer(lvals, rvals)[0]
3322+
try:
3323+
uniq_tuples = self._inner_indexer(lvals, rvals)[0]
3324+
except TypeError:
3325+
pass
33223326

3323-
other_uniq = set(rvals)
3324-
seen = set()
3325-
uniq_tuples = [
3326-
x for x in lvals if x in other_uniq and not (x in seen or seen.add(x))
3327-
]
3327+
if uniq_tuples is None:
3328+
other_uniq = set(rvals)
3329+
seen = set()
3330+
uniq_tuples = [
3331+
x for x in lvals if x in other_uniq and not (x in seen or seen.add(x))
3332+
]
33283333

33293334
if sort is None:
33303335
uniq_tuples = sorted(uniq_tuples)

0 commit comments

Comments
 (0)