searchsorted(a, v, side='left', sorter=None)
Find the indices into a sorted array a
such that, if the corresponding elements in v
were inserted before the indices, the order of a
would be preserved.
Assuming that a
is sorted:
====== ============================ :None:None:`side`
returned index i
satisfies ====== ============================ left a[i-1] < v <= a[i]
right a[i-1] <= v < a[i]
====== ============================
Binary search is used to find the required insertion points.
As of NumPy 1.4.0 searchsorted
works with real/complex arrays containing :None:None:`nan`
values. The enhanced sort order is documented in sort
.
This function uses the same algorithm as the builtin python bisect.bisect_left
( side='left'
) and bisect.bisect_right
( side='right'
) functions, which is also vectorized in the v
argument.
Input array. If :None:None:`sorter`
is None, then it must be sorted in ascending order, otherwise :None:None:`sorter`
must be an array of indices that sort it.
Values to insert into a
.
If 'left', the index of the first suitable location found is given. If 'right', return the last such index. If there is no suitable index, return either 0 or N (where N is the length of a
).
Optional array of integer indices that sort array a into ascending order. They are typically the result of argsort.
Array of insertion points with the same shape as v
, or an integer if v
is a scalar.
Find indices where elements should be inserted to maintain order.
histogram
Produce histogram from 1-D data.
sort
Return a sorted copy of an array.
>>> np.searchsorted([1,2,3,4,5], 3) 2
>>> np.searchsorted([1,2,3,4,5], 3, side='right') 3
>>> np.searchsorted([1,2,3,4,5], [-10, 10, 2, 3]) array([0, 5, 1, 2])See :
The following pages refer to to this document either explicitly or contain code examples using this.
pandas.core.arrays._mixins.NDArrayBackedExtensionArray.searchsorted
numpy.ma.core.MaskedArray.sort
numpy.searchsorted
pandas.core.arrays.base.ExtensionArray.searchsorted
pandas.core.algorithms.searchsorted
pandas.core.series.Series.searchsorted
numpy.digitize
pandas.core.base.IndexOpsMixin.searchsorted
numpy.histogram
numpy.lib.histograms._search_sorted_inclusive
numpy.sort
dask.array.routines.searchsorted
Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.
Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)
SVG is more flexible but power hungry; and does not scale well to 50 + nodes.
All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them