numpy.select(condlist, choicelist, default=0)
[source]
Return an array drawn from elements in choicelist, depending on conditions.
Parameters: |
condlist : list of bool ndarrays The list of conditions which determine from which array in choicelist : list of ndarrays The list of arrays from which the output elements are taken. It has to be of the same length as default : scalar, optional The element inserted in |
---|---|
Returns: |
output : ndarray The output at position m is the m-th element of the array in |
See also
where
>>> x = np.arange(10) >>> condlist = [x<3, x>5] >>> choicelist = [x, x**2] >>> np.select(condlist, choicelist) array([ 0, 1, 2, 0, 0, 0, 36, 49, 64, 81])
© 2008–2017 NumPy Developers
Licensed under the NumPy License.
https://docs.scipy.org/doc/numpy-1.13.0/reference/generated/numpy.select.html