I'm having a weird problem that I can't fix. I've created a Numpy array named arr
:
import numpy as np
v1 = 1
e1 = [1, 2]
arr1 = [v1, e1] # Numpy array's first element
v2 = 2
e2 = [3, 5]
arr2 = [v2, e2] # Numpy array's second element
arr = np.array([arr1, arr2]) # My Numpy array
# array([[1, list([1, 2])],
# [2, list([3, 5])]], dtype=object)
I want to find the position(s) of the list [3, 5]
in the array arr
(of course, by taking into account the placement of the list
object in the latter [2nd column of each line]). So, I tried this command:
arr[:, 1] == [3, 5]
# array([False, False])
However, I am supposed to get: array([False, True])
(The list [3, 5]
exists in the second line of arr
).
To verify, I've tried to test the equality manually. Everything is ok, I've got expected results:
arr[:, 1][0] == [3, 5] # False
arr[:, 1][1] == [3, 5] # True
So, why by using the equality between arr
and [3, 5]
I've got array([False, False])
instead of array([False, True])
?