I have an array (dtype=object) with the first column containing tuples of arrays and the second column containing scalars. I want all scalars from the second column where the tuples in the first column equal a certain tuple.
Say
>>> X
array([[(array([ 21.]), array([ 13.])), 0.29452519286647716],
[(array([ 25.]), array([ 9.])), 0.9106600600510809],
[(array([ 25.]), array([ 13.])), 0.8137344043493814],
[(array([ 25.]), array([ 14.])), 0.8143093864975313],
[(array([ 25.]), array([ 15.])), 0.6004337591112664],
[(array([ 25.]), array([ 16.])), 0.6239450452872853],
[(array([ 21.]), array([ 13.])), 0.32082105959687424]], dtype=object)
and I want all rows where the 1st column equals X[0,0].
ar = X[0,0]
>>> ar
(array([ 21.]), array([ 13.]))
I thaugh checking X[:,0]==ar should find me those rows. I would had then retrieved my final result by X[X[:,0]==ar,1].
What seems to happen, however, is that ar gets to be interpreted as a 2dimensional array and each single element in ar is compared to the tuples in X[:,0]. This yields a, in this case, 2x7 array all entries equal to False. In contrast, the comparison X[0,0]==ar works just as I would want it giving a value of True.
Why is that happening and how can I fix it to obtain the desired result?