[Python] Determine whether an array contains another array

y1 = np.array([[1, 2], [1, 3], [1, 2], [2, 2]])
y2 = np.array([[100, 200], [100,300], [100, 200], [200, 200]])
z = np.array([1, 2])

(y1 == z).all(1).any()
# True
(y2 == z).all(1).any()
# False

Reference: About python: Check whether the NumPy array contains another array

Guess you like

Origin blog.csdn.net/weixin_38705903/article/details/113104209