Setup
data = np.array([('Ram', 0, 0.), ('', 0, 0.), ('', 0, 0.), ('', 0, 0.),
('Ram', 0, 0.), ('', 0, 0.), ('', 0, 0.), ('', 0, 0.)],
dtype=[('name', '<U10'), ('token', '<i8'), ('price', '<f8')])
Look at the difference between when you index using 'name' vs. ['name']:
>>> data['name']
array(['Ram', '', '', '', 'Ram', '', '', ''], dtype='<U10')
>>> data[['name']]
array([('Ram',), ('',), ('',), ('',), ('Ram',), ('',), ('',), ('',)],
dtype=[('name', '<U10')])
This distinction is clearly defined in the documentation
Accessing Individual Fields
Individual fields of a structured array
may be accessed and modified by indexing the array with the field
name.
Accessing Multiple Fields
One can index and assign to a structured array with a multi-field index, where the index is a list of field names.
Since you want to compare a string with the values of a single field, you must access this using only the field name:
>>> np.where(data['name'] == 'Ram')
(array([0, 4], dtype=int64),)
pandas.