pandas.Index.get_indexer

pandas 3.1.1 · Index objects · method

Find where target labels would come from in this index. Unmatched labels produce -1.

Call syntax

Index.get_indexer(target, method=None, limit=None, tolerance=None)

Run the example

Edit the example and select Run Python to see the result.

Parameters

ParameterRequirementAccepted values and behavior
target Required
Positional or keyword
Index

Supply the labels to align or match against.

method Optional
Positional or keyword
Default None
{None, 'pad'/'ffill', 'backfill'/'bfill', 'nearest'}

Choose the algorithm used to calculate, align, or fill the result.

limit Optional
Positional or keyword
Default None
int

Set a maximum number of items affected by the operation.

tolerance Optional
Positional or keyword
Default None
Any

Set the maximum acceptable distance for an inexact match.

Returns

np.ndarray[np.intp]