Numpy.where()

官方文檔  html

numpy.where(condition[, x, y])ui

return elements , either from x or y , depending on condition.htm

if only condtion is given , return condition.nonzero().ip

Parameters : condition :array_like , bool When True, yield x, otherwise yield y.ci

                    x,y : array_like, optional Values from which to choose. x,y and condition need to be broadcastable to some shape.element

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.get

                    if only condition is given, return the tuple[condtion.nonzero()], the indices where condition is True.input

 

Notes:   if x and y are given and input arrays are 1-D , where is equivialent to:it

[xv if c else yv for (c, xv, yv) in zip(condition, x,y)

相關文章
相關標籤/搜索