Not able to print cell value by index.

0 votes

Hi. I am trying to print a cell value using the index and the column name. The dataframe is as follows:

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

Using this code:

print (df.iloc['0'][‘Age’])

But it is not printing anything.

Apr 8, 2019 in Python by Raj
39 views

1 answer to this question.

0 votes

You have wrongly indexed. The index you have to use is an integer 0 but you are using a character ‘0’. Try this:

print (df.iloc[0][‘Age’])

It should work.

answered Apr 8, 2019 by Ganesh

Related Questions In Python

0 votes
1 answer

How to sort Counter by value using python?

Use the Counter.most_common() method, it'll sort the items for you: >>> ...READ MORE

answered May 22, 2018 in Python by charlie_brown
• 7,760 points
3,480 views
0 votes
1 answer

How to print a message or the error if a file is not found?

To print the message that file is not ...READ MORE

answered Jan 2, 2019 in Python by Omkar
• 69,000 points
81 views
0 votes
1 answer

Not able to take input in python

You are using python 2 in which ...READ MORE

answered Jan 31, 2019 in Python by Omkar
• 69,000 points
139 views
+1 vote
1 answer

Not able to Import scikitplot package in my Jupyter Lab

To overcome this issue, you need to ...READ MORE

answered Feb 21, 2019 in Python by Yami
2,248 views
0 votes
1 answer

How to rename columns in pandas (Python)?

It is easy by just adding ".columns" ...READ MORE

answered Apr 30, 2018 in Data Analytics by DeepCoder786
• 1,720 points
250 views
0 votes
1 answer

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

The major difference is size includes NaN ...READ MORE

answered Apr 30, 2018 in Data Analytics by DeepCoder786
• 1,720 points
895 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
4,252 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,507 views
0 votes
1 answer

How to sort dictionary by value python

This would work: d = sorted(data, key = ...READ MORE

answered Nov 2, 2018 in Python by Nabarupa
113 views
+1 vote
2 answers

Not able to install speech_recognition in python: ModuleNotFoundError: No module named 'speech_recognition'

Hey. You have to use SpeechRecognition as module ...READ MORE

answered Nov 28, 2018 in Python by Omkar
• 69,000 points
6,359 views