@@ -3394,6 +3394,9 @@ def get_indexer(
3394
3394
if not self ._index_as_unique :
3395
3395
raise InvalidIndexError (self ._requires_unique_msg )
3396
3396
3397
+ if len (target ) == 0 :
3398
+ return np .array ([], dtype = np .intp )
3399
+
3397
3400
if not self ._should_compare (target ) and not is_interval_dtype (self .dtype ):
3398
3401
# IntervalIndex get special treatment bc numeric scalars can be
3399
3402
# matched to Interval scalars
@@ -3402,9 +3405,14 @@ def get_indexer(
3402
3405
if is_categorical_dtype (target .dtype ):
3403
3406
# potential fastpath
3404
3407
# get an indexer for unique categories then propagate to codes via take_nd
3405
- # Note: calling get_indexer instead of _get_indexer causes
3406
- # RecursionError GH#42088
3407
- categories_indexer = self ._get_indexer (target .categories )
3408
+ if is_categorical_dtype (self .dtype ):
3409
+ # Avoid RecursionError GH#42088
3410
+ categories_indexer = self ._get_indexer (target .categories )
3411
+ else :
3412
+ # get_indexer instead of _get_indexer needed for MultiIndex cases
3413
+ # e.g. test_append_different_columns_types
3414
+ categories_indexer = self .get_indexer (target .categories )
3415
+
3408
3416
indexer = algos .take_nd (categories_indexer , target .codes , fill_value = - 1 )
3409
3417
3410
3418
if (not self ._is_multi and self .hasnans ) and target .hasnans :
@@ -5341,6 +5349,14 @@ def _maybe_promote(self, other: Index) -> tuple[Index, Index]:
5341
5349
# TODO: may need itemsize check if we have non-64-bit Indexes
5342
5350
return self , other .astype (self .dtype )
5343
5351
5352
+ elif self ._is_multi and not other ._is_multi :
5353
+ try :
5354
+ # "Type[Index]" has no attribute "from_tuples"
5355
+ other = type (self ).from_tuples (other ) # type: ignore[attr-defined]
5356
+ except (TypeError , ValueError ):
5357
+ # let's instead try with a straight Index
5358
+ self = Index (self ._values )
5359
+
5344
5360
if not is_object_dtype (self .dtype ) and is_object_dtype (other .dtype ):
5345
5361
# Reverse op so we dont need to re-implement on the subclasses
5346
5362
other , self = other ._maybe_promote (self )
0 commit comments