File tree 1 file changed +16
-3
lines changed
1 file changed +16
-3
lines changed Original file line number Diff line number Diff line change @@ -3407,12 +3407,25 @@ def get_indexer(
3407
3407
# matched to Interval scalars
3408
3408
return self ._get_indexer_non_comparable (target , method = method , unique = True )
3409
3409
3410
+ if is_categorical_dtype (self .dtype ):
3411
+ # _maybe_cast_listlike_indexer ensures target has our dtype
3412
+ # (could improve perf by doing _should_compare check earlier?)
3413
+ assert is_dtype_equal (self .dtype , target .dtype )
3414
+
3415
+ indexer = self ._engine .get_indexer (target .codes )
3416
+ if self .hasnans and target .hasnans :
3417
+ loc = self .get_loc (np .nan )
3418
+ mask = target .isna ()
3419
+ indexer [mask ] = loc
3420
+ return indexer
3421
+
3410
3422
if is_categorical_dtype (target .dtype ):
3411
3423
# potential fastpath
3412
3424
# get an indexer for unique categories then propagate to codes via take_nd
3413
- # Note: calling get_indexer instead of _get_indexer causes
3414
- # RecursionError GH#42088
3415
- categories_indexer = self ._get_indexer (target .categories )
3425
+ # get_indexer instead of _get_indexer needed for MultiIndex cases
3426
+ # e.g. test_append_different_columns_types
3427
+ categories_indexer = self .get_indexer (target .categories )
3428
+
3416
3429
indexer = algos .take_nd (categories_indexer , target .codes , fill_value = - 1 )
3417
3430
3418
3431
if (not self ._is_multi and self .hasnans ) and target .hasnans :
You can’t perform that action at this time.
0 commit comments