python - How can I check if each row in a matrix is equal to an array and return a Boolean array containing the result? -
how can check if each row in matrix equal array , return boolean array containing result using numpy? e.g.
a = np.array([[1,2,3],[4,5,6],[7,8,9]]) b = np.array([4,5,6]) # expected result: [false,true,false]
the neatest way i've found of doing this, is:
result = np.all(a==b, axis=1)
Comments
Post a Comment