Python

How to find index of element in dataframe Python ?

NI Asked by Nicholas · 14-06-2021
0 upvotes 12 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)
NA 29-09-2021

Thanks a lot, this helped me to.

YE 19-08-2021

It worked. Thanks

GI 18-07-2021

find positions of a single value in a dataframe

Share your thoughts

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

Professional Counselling Session

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.

Request a Call Back

Search Online

We Accept

We Accept

Follow Us

"PMI®", "PMBOK®", "PMP®", "CAPM®" and "PMI-ACP®" are registered marks of the Project Management Institute, Inc. | "CSM", "CST" are Registered Trade Marks of The Scrum Alliance, USA. | COBIT® is a trademark of ISACA® registered in the United States and other countries.

Book Free Session