numpy.where(condition[, x, y])
return elements , either from x or y , depending on condition.
if only condtion is given , return condition.nonzero().
Parameters : condition :array_like , bool When True, yield x, otherwise yield y.
x,y : array_like, optional Values from which to choose. x,y and condition need to be broadcastable to some shape.
Returns: out : ndarray or tuple of ndarrays
if both x and y are specified , the output array contains lements of x where condition is True, and elements from y elsewhere.
if only condition is given, return the tuple[condtion.nonzero()], the indices where condition is True.
Notes: if x and y are given and input arrays are 1-D , where is equivialent to:
[xv if c else yv for (c, xv, yv) in zip(condition, x,y)