numpy 1.22.4 Pypi GitHub Homepage
Other Docs
ParametersReturnsBackRef
extract(condition, arr)

This is equivalent to np.compress(ravel(condition), ravel(arr)) . If :None:None:`condition` is boolean np.extract is equivalent to arr[condition] .

Note that place does the exact opposite of extract .

Parameters

condition : array_like

An array whose nonzero or True entries indicate the elements of :None:None:`arr` to extract.

arr : array_like

Input array of the same size as :None:None:`condition`.

Returns

extract : ndarray

Rank 1 array of values from :None:None:`arr` where :None:None:`condition` is True.

Return the elements of an array that satisfy some condition.

See Also

compress
copyto
place
put
take

Examples

>>> arr = np.arange(12).reshape((3, 4))
... arr array([[ 0, 1, 2, 3], [ 4, 5, 6, 7], [ 8, 9, 10, 11]])
>>> condition = np.mod(arr, 3)==0
... condition array([[ True, False, False, True], [False, False, True, False], [False, True, False, False]])
>>> np.extract(condition, arr)
array([0, 3, 6, 9])

If :None:None:`condition` is boolean:

>>> arr[condition]
array([0, 3, 6, 9])
See :

Back References

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

dask.array.routines.extract numpy.compress numpy.place numpy.extract

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#1832
type: <class 'function'>
Commit: