@@ -3782,17 +3782,23 @@ def get_loc(self, key):
37823782 self ._check_indexing_error (key )
37833783 raise
37843784
3785- _index_shared_docs [
3786- "get_indexer"
3787- ] = """
3785+ @final
3786+ def get_indexer (
3787+ self ,
3788+ target ,
3789+ method : ReindexMethod | None = None ,
3790+ limit : int | None = None ,
3791+ tolerance = None ,
3792+ ) -> npt .NDArray [np .intp ]:
3793+ """
37883794 Compute indexer and mask for new index given the current index.
37893795
37903796 The indexer should be then used as an input to ndarray.take to align the
37913797 current data to the new index.
37923798
37933799 Parameters
37943800 ----------
3795- target : %(target_klass)s
3801+ target : Index
37963802 method : {None, 'pad'/'ffill', 'backfill'/'bfill', 'nearest'}, optional
37973803 * default: exact matches only.
37983804 * pad / ffill: find the PREVIOUS index value if no exact match.
@@ -3819,7 +3825,7 @@ def get_loc(self, key):
38193825 Integers from 0 to n - 1 indicating that the index at these
38203826 positions matches the corresponding target values. Missing values
38213827 in the target are marked by -1.
3822- %(raises_section)s
3828+
38233829 Notes
38243830 -----
38253831 Returns -1 for unmatched values, for further explanation see the
@@ -3834,16 +3840,6 @@ def get_loc(self, key):
38343840 Notice that the return value is an array of locations in ``index``
38353841 and ``x`` is marked by -1, as it is not in ``index``.
38363842 """
3837-
3838- @Appender (_index_shared_docs ["get_indexer" ] % _index_doc_kwargs )
3839- @final
3840- def get_indexer (
3841- self ,
3842- target ,
3843- method : ReindexMethod | None = None ,
3844- limit : int | None = None ,
3845- tolerance = None ,
3846- ) -> npt .NDArray [np .intp ]:
38473843 method = clean_reindex_fill_method (method )
38483844 orig_target = target
38493845 target = self ._maybe_cast_listlike_indexer (target )
@@ -3898,7 +3894,7 @@ def get_indexer(
38983894
38993895 return ensure_platform_int (indexer )
39003896
3901- pself , ptarget = self ._maybe_promote (target )
3897+ pself , ptarget = self ._maybe_downcast_for_indexing (target )
39023898 if pself is not self or ptarget is not target :
39033899 return pself .get_indexer (
39043900 ptarget , method = method , limit = limit , tolerance = tolerance
@@ -4582,7 +4578,7 @@ def join(
45824578
45834579 if not self ._is_multi and not other ._is_multi :
45844580 # We have specific handling for MultiIndex below
4585- pself , pother = self ._maybe_promote (other )
4581+ pself , pother = self ._maybe_downcast_for_indexing (other )
45864582 if pself is not self or pother is not other :
45874583 return pself .join (
45884584 pother , how = how , level = level , return_indexers = True , sort = sort
@@ -6046,7 +6042,7 @@ def get_indexer_non_unique(
60466042 # that can be matched to Interval scalars.
60476043 return self ._get_indexer_non_comparable (target , method = None , unique = False )
60486044
6049- pself , ptarget = self ._maybe_promote (target )
6045+ pself , ptarget = self ._maybe_downcast_for_indexing (target )
60506046 if pself is not self or ptarget is not target :
60516047 return pself .get_indexer_non_unique (ptarget )
60526048
@@ -6062,8 +6058,8 @@ def get_indexer_non_unique(
60626058 # TODO: get_indexer has fastpaths for both Categorical-self and
60636059 # Categorical-target. Can we do something similar here?
60646060
6065- # Note: _maybe_promote ensures we never get here with MultiIndex
6066- # self and non-Multi target
6061+ # Note: _maybe_downcast_for_indexing ensures we never get here
6062+ # with MultiIndex self and non-Multi target
60676063 tgt_values = target ._get_engine_target ()
60686064 if self ._is_multi and target ._is_multi :
60696065 engine = self ._engine
@@ -6237,7 +6233,7 @@ def _index_as_unique(self) -> bool:
62376233 _requires_unique_msg = "Reindexing only valid with uniquely valued Index objects"
62386234
62396235 @final
6240- def _maybe_promote (self , other : Index ) -> tuple [Index , Index ]:
6236+ def _maybe_downcast_for_indexing (self , other : Index ) -> tuple [Index , Index ]:
62416237 """
62426238 When dealing with an object-dtype Index and a non-object Index, see
62436239 if we can upcast the object-dtype one to improve performance.
@@ -6278,7 +6274,7 @@ def _maybe_promote(self, other: Index) -> tuple[Index, Index]:
62786274
62796275 if not is_object_dtype (self .dtype ) and is_object_dtype (other .dtype ):
62806276 # Reverse op so we dont need to re-implement on the subclasses
6281- other , self = other ._maybe_promote (self )
6277+ other , self = other ._maybe_downcast_for_indexing (self )
62826278
62836279 return self , other
62846280
0 commit comments