How to find the index of a particular value in a dataframe?

0 votes

Hi. I have a pandas dataframe and I want to find the index of a particular entry in 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?

Apr 8, 2019 in Python by Raj
24,684 views

1 answer to this question.

+1 vote

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

print(df[df[‘Name’]==’Donna’].index.values)
answered Apr 8, 2019 by Esha
what if i know the index and i want to print the age

Hey,

You can do like this:

dic = {'Name': ["Donna"], 'Age': [23]}
pd.DataFrame(data=dic)

Related Questions In Python

–1 vote
2 answers

How to find the size of a string in Python?

following way to find length of string  x ...READ MORE

answered Mar 29, 2019 in Python by rajesh
• 1,230 points
244 views
0 votes
1 answer

How to find the sum of rows in Pandas dataframe?

You can use a combination groupby function with the sum() method. ...READ MORE

answered May 9, 2019 in Python by Jisha
1,850 views
0 votes
1 answer

How to print the index of a Pandas Dataframe?

You can do this using the code ...READ MORE

answered May 12, 2019 in Python by Usha
1,422 views
0 votes
1 answer

How to check if a value exists in pandas dataframe index?

Hello @kartik, Basically instead of raising exception I ...READ MORE

answered Jun 15 in Python by Niroj
• 35,660 points
153 views
0 votes
1 answer

How to rename columns in pandas (Python)?

You can use the rename function in ...READ MORE

answered Apr 30, 2018 in Data Analytics by DeepCoder786
• 1,720 points

edited Jun 8 by MD 372 views
0 votes
1 answer

What is the Difference in Size and Count in pandas (python)?

The major difference is "size" includes NaN values, ...READ MORE

answered Apr 30, 2018 in Data Analytics by DeepCoder786
• 1,720 points

edited Jun 8 by Gitika 1,040 views
0 votes
2 answers

Replacing a row in pandas data.frame

key error. I love python READ MORE

answered Feb 18, 2019 in Data Analytics by anonymous
5,649 views
0 votes
1 answer

Converting a pandas data-frame to a dictionary

Emp_dict=Employee.to_dict('records') You can directly use the 'to_dict()' function ...READ MORE

answered May 23, 2018 in Data Analytics by Bharani
• 4,560 points
2,957 views
0 votes
1 answer

How to find the value of a row in a csv file in python?

If you want to find the value ...READ MORE

answered May 20, 2019 in Python by Sanam
167 views
0 votes
1 answer

How to find if a value exists in Pandas dataframe?

Try this:​ for name in df['Name']: ...READ MORE

answered Apr 8, 2019 in Python by Tina
7,377 views