@@ -399,9 +399,9 @@ def reindex(
399
399
indexer = None
400
400
missing = np .array ([], dtype = np .intp )
401
401
else :
402
- indexer , missing = self .get_indexer_non_unique (np . array ( target ) )
402
+ indexer , missing = self .get_indexer_non_unique (target )
403
403
404
- if len (self . codes ) and indexer is not None :
404
+ if len (self ) and indexer is not None :
405
405
new_target = self .take (indexer )
406
406
else :
407
407
new_target = target
@@ -410,10 +410,8 @@ def reindex(
410
410
if len (missing ):
411
411
cats = self .categories .get_indexer (target )
412
412
413
- if not isinstance (cats , CategoricalIndex ) or (cats == - 1 ).any ():
414
- # coerce to a regular index here!
415
- result = Index (np .array (self ), name = self .name )
416
- new_target , indexer , _ = result ._reindex_non_unique (target )
413
+ if not isinstance (target , CategoricalIndex ) or (cats == - 1 ).any ():
414
+ new_target , indexer , _ = super ()._reindex_non_unique (target )
417
415
else :
418
416
419
417
codes = new_target .codes .copy ()
@@ -426,11 +424,12 @@ def reindex(
426
424
# coerce based on the actual values, only on the dtype)
427
425
# unless we had an initial Categorical to begin with
428
426
# in which case we are going to conform to the passed Categorical
429
- new_target = np .asarray (new_target )
430
427
if is_categorical_dtype (target ):
431
428
cat = Categorical (new_target , dtype = target .dtype )
432
429
new_target = type (self )._simple_new (cat , name = self .name )
433
430
else :
431
+ # e.g. test_reindex_with_categoricalindex, test_reindex_duplicate_target
432
+ new_target = np .asarray (new_target )
434
433
new_target = Index (new_target , name = self .name )
435
434
436
435
return new_target , indexer
0 commit comments