Numpy: bitwise and by array

I am trying to do "&". operations on all values ​​in a simple bool array. The array I have looks like this:

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

      

The only thing I came up with was to cut off the values ​​in the array and use "&" to get a "false" result. I feel like there should be a better way, but I don't know enough about numpy to use it correctly.

+3


source to share


1 answer


Use arr.all()

what is the same as np.all(arr)

:



import numpy as np
arr = np.array([False, False, True], dtype=bool) 
arr.all()
=> False
np.all(arr)
=> False

      

+2


source







All Articles