numpy 1.22.4 Pypi GitHub Homepage
Other Docs
ParametersReturnsBackRef
select(condlist, choicelist, default=0)

Parameters

condlist : list of bool ndarrays

The list of conditions which determine from which array in :None:None:`choicelist` the output elements are taken. When multiple conditions are satisfied, the first one encountered in :None:None:`condlist` is used.

choicelist : list of ndarrays

The list of arrays from which the output elements are taken. It has to be of the same length as :None:None:`condlist`.

default : scalar, optional

The element inserted in output when all conditions evaluate to False.

Returns

output : ndarray

The output at position m is the m-th element of the array in :None:None:`choicelist` where the m-th element of the corresponding array in :None:None:`condlist` is True.

Return an array drawn from elements in choicelist, depending on conditions.

See Also

choose
compress
diag
diagonal
take
where

Return elements from one of two arrays depending on condition.

Examples

>>> x = np.arange(6)
... condlist = [x<3, x>3]
... choicelist = [x, x**2]
... np.select(condlist, choicelist, 42) array([ 0, 1, 2, 42, 16, 25])
>>> condlist = [x<=4, x>3]
... choicelist = [x, x**2]
... np.select(condlist, choicelist, 55) array([ 0, 1, 2, 3, 4, 25])
See :

Back References

The following pages refer to to this document either explicitly or contain code examples using this.

numpy.piecewise dask.array.routines.select numpy.compress

Local connectivity graph

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


GitHub : /numpy/lib/function_base.py#741
type: <class 'function'>
Commit: