I have an array my_array containing some tuple data.
I have another array my_array_values of same length containing some integer values.
For each unique value of my_array_values, I want to retrieve a list of values from my_array, that are in the same index as this value in my_array_values. Here is my code and the expected behavior :
my_array = np.array([('AA','11'),('BB','22'),('CC','33'),('DD','44'),('EE','55'),('FF','66')])
my_array_values = np.array([1,2,3,1,3,2])
my_array_values_unique = np.array([1,2,3])
for v in my_array_values_unique:
print(np.take(my_array, np.where(my_array_values == v)))
Expected behavior :
[('AA', '11'), ('DD', '44')]
[('BB', '22'), ('FF', '66')]
[('CC', '33'), ('EE', '55')]
But actually, my code gives me the following output:
[['AA' '22']]
[['11' '33']]
[['BB' 'CC']]
Can someone explain to me how I can get the correct output?