pandas.Index.searchsorted

pandas 3.1.1 · Index objects · method

Get the insertion positions that preserve the order of sorted data.

Call syntax

Index.searchsorted(value, side='left', sorter=None)

Run the example

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

Parameters

ParameterRequirementAccepted values and behavior
value Required
Positional or keyword
array-like or scalar

Provide the value used for the documented operation, such as a replacement or a test point.

side Optional
Positional or keyword
Default 'left'
{'left', 'right'}

Choose the side of the search, interval, or padding operation.

sorter Optional
Positional or keyword
Default None
1-D array-like

Supply positions that place the input in sorted order.

Returns

int or array of int