Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Check if single element is contained in Numpy Array

I just want to check if a numpy array contains a single number quickly similar to contains for a list. Is there a concise way to do this?

a = np.array(9,2,7,0)
a.contains(0)  == true
like image 794
pd109 Avatar asked Jul 12 '17 15:07

pd109


1 Answers

You can use 0 in a. i.e

a = np.array([9,2,7,0])
0 in a
like image 71
Bharath Avatar answered Sep 28 '22 00:09

Bharath