I have a 2D numpy array with a shape (3, 3) and dtype=object whose elements are tuples of the form (str, str, float).
template = ('Apple', 'Orange', 5.0)
my_array = np.array([None] * 9).reshape((3,3))
for i in range(my_array.shape[0]):
for j in range(my_array.shape[1]):
my_array[i, j] = template
But when I try to get a boolean mask
print(my_array == template)
The answer is all False
[[False False False]
[False False False]
[False False False]]
However element-wise comparison still works
print(my_array[0,0] == template) # This prints True
Why does the boolean mask return all False and how do I make it work?
P.S. I have searched for relevant topics but couldn't make use of any...
Array of tuples in Python
Restructuring Array of Tuples
Apply function to an array of tuples
Filter numpy array of tuples