@@ -365,7 +365,6 @@ def __contains__(self, key: Any) -> bool:
365
365
366
366
return contains (self , key , container = self ._engine )
367
367
368
- # TODO(2.0): remove reindex once non-unique deprecation is enforced
369
368
def reindex (
370
369
self , target , method = None , level = None , limit = None , tolerance = None
371
370
) -> tuple [Index , npt .NDArray [np .intp ] | None ]:
@@ -392,51 +391,7 @@ def reindex(
392
391
raise NotImplementedError (
393
392
"argument limit is not implemented for CategoricalIndex.reindex"
394
393
)
395
-
396
- target = ibase .ensure_index (target )
397
-
398
- if self .equals (target ):
399
- indexer = None
400
- missing = np .array ([], dtype = np .intp )
401
- else :
402
- indexer , missing = self .get_indexer_non_unique (target )
403
- if not self .is_unique :
404
- # GH#42568
405
- raise ValueError ("cannot reindex on an axis with duplicate labels" )
406
-
407
- new_target : Index
408
- if len (self ) and indexer is not None :
409
- new_target = self .take (indexer )
410
- else :
411
- new_target = target
412
-
413
- # filling in missing if needed
414
- if len (missing ):
415
- cats = self .categories .get_indexer (target )
416
-
417
- if not isinstance (target , CategoricalIndex ) or (cats == - 1 ).any ():
418
- new_target , indexer , _ = super ()._reindex_non_unique (target )
419
- else :
420
- # error: "Index" has no attribute "codes"
421
- codes = new_target .codes .copy () # type: ignore[attr-defined]
422
- codes [indexer == - 1 ] = cats [missing ]
423
- cat = self ._data ._from_backing_data (codes )
424
- new_target = type (self )._simple_new (cat , name = self .name )
425
-
426
- # we always want to return an Index type here
427
- # to be consistent with .reindex for other index types (e.g. they don't
428
- # coerce based on the actual values, only on the dtype)
429
- # unless we had an initial Categorical to begin with
430
- # in which case we are going to conform to the passed Categorical
431
- if is_categorical_dtype (target ):
432
- cat = Categorical (new_target , dtype = target .dtype )
433
- new_target = type (self )._simple_new (cat , name = self .name )
434
- else :
435
- # e.g. test_reindex_with_categoricalindex, test_reindex_duplicate_target
436
- new_target_array = np .asarray (new_target )
437
- new_target = Index ._with_infer (new_target_array , name = self .name )
438
-
439
- return new_target , indexer
394
+ return super ().reindex (target )
440
395
441
396
# --------------------------------------------------------------------
442
397
# Indexing Methods
0 commit comments