Python

How to find index of element in dataframe Python ?

NI Asked by Nicholas · 14-06-2021
▲ 0 upvotes 106 views 0 comments
The question

Hi. I possess a pandas dataframe and I am seeking to identify the index of a specific entry within it.

Name Age
0 Mike 23
1 Eric 25
2 Donna 23
3 Will 23  

This is the dataframe. I want to find the index of Donna. How can I do it?

1 answer

▲ 0
HE
Answered on 20-08-2021

First, use the dataframe to match the value, and then find the index. Try this:

print(df[df[Name]==Donna].index.values)
GI 18-07-2021

find positions of a single value in a dataframe

YE 19-08-2021

It worked. Thanks

NA 29-09-2021

Thanks a lot, this helped me to.

Share your thoughts

Your email address will not be published. Required fields are marked (*)

Still have questions? Schedule a free counselling session

Our experts are ready to help you with any questions about courses, admissions, or career paths. Get personalized guidance from industry professionals.

Book Free Session

Book Free Session