Changes elements of an array based on conditional and input values.
Sets a.flat[n] = values[n] for each n where mask.flat[n]==True.
If values is not the same size as a and mask then it will repeat. This gives behavior different from a[mask] = values.
Note
The putmask functionality is also provided by copyto, which can be significantly faster and in addition is NA-aware (preservena keyword). Replacing putmask with np.copyto(a, values, where=mask) is recommended.
| Parameters : | a : array_like 
 mask : array_like 
 values : array_like 
  | 
|---|
Examples
>>> x = np.arange(6).reshape(2, 3)
>>> np.putmask(x, x>2, x**2)
>>> x
array([[ 0,  1,  2],
       [ 9, 16, 25]])
If values is smaller than a it is repeated:
>>> x = np.arange(5)
>>> np.putmask(x, x>1, [-33, -44])
>>> x
array([  0,   1, -33, -44, -33])