First page Back Continue Last page Overview Graphics

Boolean Indexing III

>>> C = np.array([123,188,190,99,77,88,100])

>>> A = np.array([4,7,2,8,6,9,5])

>>> A<=5

array([ True, False, True, False, False, False, True], dtype=bool)

Returning all the elements of C, where the corresponding value in A is less or equal than 5:

>>> C[A<=5]

array([123, 190, 100])

>>> B=A<=5

>>> C[B]

array([123, 190, 100])