numpy 1.22.4 Pypi GitHub Homepage
Other Docs
ParametersBackRef
put(a, ind, v, mode='raise')

The indexing works on the flattened target array. put is roughly equivalent to:

a.flat[ind] = v

Parameters

a : ndarray

Target array.

ind : array_like

Target indices, interpreted as integers.

v : array_like

Values to place in a at target indices. If v is shorter than :None:None:`ind` it will be repeated as necessary.

mode : {'raise', 'wrap', 'clip'}, optional

Specifies how out-of-bounds indices will behave.

  • 'raise' -- raise an error (default)

  • 'wrap' -- wrap around

  • 'clip' -- clip to the range

'clip' mode means that all indices that are too large are replaced by the index that addresses the last element along that axis. Note that this disables indexing with negative numbers. In 'raise' mode, if an exception occurs the target array may still be modified.

Replaces specified elements of an array with given values.

See Also

place
put_along_axis

Put elements by matching the array and the index arrays

putmask

Examples

>>> a = np.arange(5)
... np.put(a, [0, 2], [-44, -55])
... a array([-44, 1, -55, 3, 4])
>>> a = np.arange(5)
... np.put(a, 22, -5, mode='clip')
... a array([ 0, 1, 2, 3, -5])
See :

Back References

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

numpy.extract numpy.put numpy.place numpy.core._multiarray_umath.putmask numpy.putmask

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/core/fromnumeric.py#486
type: <class 'function'>
Commit: