@@ -715,6 +715,24 @@ def _values(self) -> np.ndarray:
715
715
arr = lib .fast_zip (values )
716
716
return arr
717
717
718
+ @cache_readonly
719
+ def _values_for_indexer (self ):
720
+ values = []
721
+
722
+ for i in range (self .nlevels ):
723
+ vals = self ._get_level_values (i )
724
+ if is_categorical_dtype (vals .dtype ):
725
+ vals = cast ("CategoricalIndex" , vals )
726
+ vals = vals ._data ._internal_get_values ()
727
+ if isinstance (vals .dtype , ExtensionDtype ):
728
+ vals = vals .astype (object )
729
+ # error: Incompatible types in assignment (expression has type "ndarray",
730
+ # variable has type "Index")
731
+ vals = np .array (vals , copy = False ) # type: ignore[assignment]
732
+ values .append (vals )
733
+
734
+ return values
735
+
718
736
@property
719
737
def values (self ) -> np .ndarray :
720
738
return self ._values
@@ -2666,6 +2684,15 @@ def _get_partial_string_timestamp_match_key(self, key):
2666
2684
2667
2685
return key
2668
2686
2687
+ def _get_engine_target (self ) -> np .ndarray :
2688
+ """
2689
+ Override base
2690
+ Get the ndarray that we can pass to the IndexEngine constructor.
2691
+ """
2692
+ # error: Incompatible return value type (got "Union[ExtensionArray,
2693
+ # ndarray]", expected "ndarray")
2694
+ return self ._values_for_indexer # type: ignore[return-value]
2695
+
2669
2696
def _get_indexer (
2670
2697
self ,
2671
2698
target : Index ,
@@ -2686,7 +2713,7 @@ def _get_indexer(
2686
2713
2687
2714
# let's instead try with a straight Index
2688
2715
if method is None :
2689
- return Index (self ._values ).get_indexer (
2716
+ return Index (self ._values_for_indexer ).get_indexer (
2690
2717
target , method = method , limit = limit , tolerance = tolerance
2691
2718
)
2692
2719
@@ -2701,15 +2728,18 @@ def _get_indexer(
2701
2728
# TODO: get_indexer_with_fill docstring says values must be _sorted_
2702
2729
# but that doesn't appear to be enforced
2703
2730
indexer = self ._engine .get_indexer_with_fill (
2704
- target = target ._values , values = self ._values , method = method , limit = limit
2731
+ target = target ._values_for_indexer ,
2732
+ values = self ._values_for_indexer ,
2733
+ method = method ,
2734
+ limit = limit ,
2705
2735
)
2706
2736
elif method == "nearest" :
2707
2737
raise NotImplementedError (
2708
2738
"method='nearest' not implemented yet "
2709
2739
"for MultiIndex; see GitHub issue 9365"
2710
2740
)
2711
2741
else :
2712
- indexer = self ._engine .get_indexer (target ._values )
2742
+ indexer = self ._engine .get_indexer (target ._values_for_indexer )
2713
2743
2714
2744
# Note: we only get here (in extant tests at least) with
2715
2745
# target.nlevels == self.nlevels
0 commit comments