### Navigation

- index
- modules |
- next |
- previous |
- NumPy v1.3 Manual (DRAFT) »
- NumPy Reference »
- Routines »
- Indexing routines »

# numpy.put

`numpy.``put`(a, ind, v, mode='raise')

  Changes specific elements of one array by replacing from another array.

  Set a.flat[n] = v[n] for all n in ind. If v is shorter than ind, it will repeat which is different than a[ind] = v.

  Parameters: | a : array_like (contiguous) Target array. ind : array_like Target indices, interpreted as integers. v : array_like Values to place in a at target indices. mode : {‘raise’, ‘wrap’, ‘clip’}, optional Specifies how out-of-bounds indices will behave. * ‘raise’ – raise an error : * ‘wrap’ – wrap around : * ‘clip’ – clip to the range :

  Notes

  If v is shorter than mask it will be repeated as necessary. In particular v can be a scalar or length 1 array. The routine put is the equivalent of the following (although the loop is in C for speed):

      ind = array(indices, copy=False)
      v = array(values, copy=False).astype(a.dtype)
      for i in ind: a.flat[i] = v[i]

  Examples

      >>> x = np.arange(5)
      >>> np.put(x,[0,2,4],[-1,-2,-3])
      >>> print x
      [-1  1 -2  3 -3]

### Navigation

- index
- modules |
- next |
- previous |
- NumPy v1.3 Manual (DRAFT) »
- NumPy Reference »
- Routines »
- Indexing routines »