Using NumPy with Python 2.7, I want to create an n-by-2 array y
. Then, I want to check whether this array contains a particular 1-by-2 array z
in any of its rows.
Here's what I have tried so far, and in this case, n = 1:
x = np.array([1, 2]) # Create a 1-by-2 array
y = [x] # Create an n-by-2 array (n = 1), and assign the first row to x
z = np.array([1, 2]) # Create another 1-by-2 array
if z in y: # Check if y contains the row z
print 'yes it is'
However, this gives me the following error:
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
What am I doing wrong?