On this page
numpy.select
numpy.select(condlist, choicelist, default=0)[source]- 
    
Return an array drawn from elements in choicelist, depending on conditions.
- Parameters
 - 
      
condlistlist of bool ndarrays- 
        
The list of conditions which determine from which array in
choicelistthe output elements are taken. When multiple conditions are satisfied, the first one encountered incondlistis used. choicelistlist of ndarrays- 
        
The list of arrays from which the output elements are taken. It has to be of the same length as
condlist. defaultscalar, optional- 
        
The element inserted in
outputwhen all conditions evaluate to False. 
 - Returns
 - 
      
outputndarray- 
        
The output at position m is the m-th element of the array in
choicelistwhere the m-th element of the corresponding array incondlistis True. 
 
See also
Examples
>>> x = np.arange(10) >>> condlist = [x<3, x>5] >>> choicelist = [x, x**2] >>> np.select(condlist, choicelist) array([ 0, 1, 2, ..., 49, 64, 81]) 
© 2005–2021 NumPy Developers
Licensed under the 3-clause BSD License.
 https://numpy.org/doc/1.20/reference/generated/numpy.select.html