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 in Python by Raj
13 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 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,710 points
1,352 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 in Python by Omkar
• 67,120 points
17 views
0 votes
1 answer

Not able to take input in python

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

answered Jan 31 in Python by Omkar
• 67,120 points
26 views
0 votes
1 answer

Not able to Import scikitplot package in my Jupyter Lab

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

answered Feb 21 in Python by Yami
326 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,700 points
74 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,700 points
645 views
0 votes
2 answers
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,550 points
976 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
52 views
0 votes
2 answers