Sometimes, we want to test whether a Numpy array contains a given row with Python.
In this article, we’ll look at how to test whether a Numpy array contains a given row with Python.
How to test whether a Numpy array contains a given row with Python?
To test whether a Numpy array contains a given row with Python, we can use the np.any
method.
For instance, we write
np.any(np.all(a == b, axis=1))
to check any rows in a
is the same as b
by calling np.all
with a == b
.
And then we call np.any
to check if there’re any such matches,.
Conclusion
To test whether a Numpy array contains a given row with Python, we can use the np.any
method.