om_fields ](pandas.PeriodIndex.from_fields.html)
    * [ pandas.PeriodIndex.from_ordinals ](pandas.PeriodIndex.from_ordinals.html)
  * [ Date offsets ](../offset_frequency.html)
  * [ Window ](../window.html)
  * [ GroupBy ](../groupby.html)
  * [ Resampling ](../resampling.html)
  * [ Style ](../style.html)
  * [ Plotting ](../plotting.html)
  * [ Options and settings ](../options.html)
  * [ Extensions ](../extensions.html)
  * [ Testing ](../testing.html)
  * [ Missing values ](../missing_value.html)

  * [ __ ](../../index.html)
  * [ API reference ](../index.html)
  * __
  * [ pandas.MultiIndex ](pandas.MultiIndex.html)
  * pandas.Multi... 

#  pandas.MultiIndex.get_indexer  #

MultiIndex.  get_indexer  (  _ target  _ , _ method  =  None  _ , _ limit  =
None  _ , _ tolerance  =  None  _ )  [ [source]  ](https://github.com/pandas-
dev/pandas/blob/v2.2.2/pandas/core/indexes/base.py#L3820-L3953) #

    

Compute indexer and mask for new index given the current index.

The indexer should be then used as an input to ndarray.take to align the
current data to the new index.

Parameters  :

    

**target** Index

    
**method** {None, âpadâ/âffillâ, âbackfillâ/âbfillâ,
ânearestâ}, optional

    

  * default: exact matches only. 

  * pad / ffill: find the PREVIOUS index value if no exact match. 

  * backfill / bfill: use NEXT index value if no exact match 

  * nearest: use the NEAREST index value if no exact match. Tied distances are broken by preferring the larger index value. 

**limit** int, optional

    

Maximum number of consecutive labels in ` target  ` to match for inexact
matches.

**tolerance** optional

    

Maximum distance between original and new labels for inexact matches. The
values of the index at the matching locations must satisfy the equation `
abs(index[indexer]  -  target)  <=  tolerance  ` .

Tolerance may be a scalar value, which applies the same tolerance to all
values, or list-like, which applies variable tolerance per element. List-like
includes list, tuple, array, Series, and must be the same size as the index
and its dtype must exactly match the indexâs type.

Returns  :

    

np.ndarray[np.intp]

    

Integers from 0 to n - 1 indicating that the index at these positions matches
the corresponding target values. Missing values in the target are marked by
-1.

Notes

Returns -1 for unmatched values, for further explanation see the example
below.

Examples

    
    
    >>> index = pd.Index(['c', 'a', 'b'])
    >>> index.get_indexer(['a', 'b', 'x'])
    array([ 1,  2, -1])
    

Notice that the return value is an array of locations in ` index  ` and ` x  `
is marked by -1, as it is not in ` index  ` .

[ __ previous  pandas.MultiIndex.get_level_values
](pandas.MultiIndex.get_level_values.html "previous page") [ next
pandas.MultiIndex.get_loc  __ ](pandas.MultiIndex.get_loc.html "next page")

__ On this page

  * ` MultiIndex.get_indexer()  `

[ __ Show Source
](../../_sources/reference/api/pandas.MultiIndex.get_indexer.rst.txt)

© 2024, pandas via [ NumFOCUS, Inc. ](https://numfocus.org) Hosted by [
OVHcloud ](https://www.ovhcloud.com) .

Created using [ Sphinx ](https://www.sphinx-doc.org/) 7.2.6.  

Built with the [ PyData Sphinx Theme ](https://pydata-sphinx-
theme.readthedocs.io/en/stable/index.html) 0.14.4.