Your array has two tuples:
In [53]: groups=np.array([('Species1',), ('Species2', 'Species3')], dtype=object)
In [54]: groups
Out[54]: array([('Species1',), ('Species2', 'Species3')], dtype=object)
In [55]: groups.shape
Out[55]: (2,)
But be careful with that kind of definition. If the tuples were all the same size, the array would have a different shape, and the elements would no longer be tuples.
In [56]: np.array([('Species1',), ('Species2',), ('Species3',)], dtype=object)
Out[56]:
array([['Species1'],
['Species2'],
['Species3']], dtype=object)
In [57]: _.shape
Out[57]: (3, 1)
Any use of where
is only as good as the boolean array given to it. This where
returns empty because the equality test produces all False
:
In [58]: np.where(groups == groups[1])
Out[58]: (array([], dtype=int64),)
In [59]: groups == groups[1]
Out[59]: array([False, False])
If I use a list comprehension to compare the group elements:
In [60]: [g == groups[1] for g in groups]
Out[60]: [False, True]
In [61]: np.where([g == groups[1] for g in groups])
Out[61]: (array([1]),)
But for this sort of thing, a list would be just as good
In [66]: alist = [('Species1',), ('Species2', 'Species3')]
In [67]: alist.index(alist[1])
Out[67]: 1
In [68]: alist.index(('Species1',))
Out[68]: 0
In [69]: alist.index(('Species2',))
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-69-0b16b56ad28c> in <module>
----> 1 alist.index(('Species2',))
ValueError: ('Species2',) is not in list