I guess this is a duplicate of Find element's index in pandas Series .
This is my dataframe;
WORD1 CAT1
elephant animal
lion animal
tiger animal
hoopoe bird
hornbill bird
sunflower flower
rose flower
giraffe animal
zebra animal
sparrow bird
duck animal
I would like to get the index of each element from 'CAT1';
Let me put it this way;
for d in data['CAT1']:
print data[data['CAT1'] == d].index[0]
...
0
0
0
3
3
5
5
0
0
3
0
The above returns the index, but falters when there are duplicates. How do I get this rectified?