numpy array indexing a bool code example
Example: python numpy array boolean indexing
x = np.array([1., -1., -2., 3])
x[x < 0] = 20
x
Output:
array([ 1., 20., 20., 3.])
x = np.array([1., -1., -2., 3])
x[x < 0] = 20
x
Output:
array([ 1., 20., 20., 3.])