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
47,799 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)
if you know the index and you want to get the age then use

print(df.loc[index, 'age'])

Related Questions In Python

0 votes
1 answer

How to find the value of a row in a csv file in python and print column and row of that value ?

Hello @Khanhh , Use panda to find the value of ...READ MORE

answered Oct 15 in Python by Niroj
• 67,020 points
73 views
–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
320 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
2,270 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
3,993 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 484 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,210 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
6,872 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,580 points
3,218 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
508 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
8,482 views