numpy.place

numpy.place(arr, mask, vals)

Changes elements of an array based on conditional and input values.

Similar to putmask(a, mask, vals) but the 1D array vals has the same number of elements as the non-zero values of mask. Inverse of extract.

Sets a.flat[n] = values[n] for each n where mask.flat[n] is true.

Parameters:

a : array_like

Array to put data into.

mask : array_like

Boolean mask array.

values : array_like, shape(number of non-zero mask, )

Values to put into a.

See also

putmask, put, take

Previous topic

numpy.select

Next topic

numpy.put

This Page

Quick search