How to select a single column in Pandas?

0 votes
I am using Pandas from some time now. I have a dataframe in pandas and there are multiple columns name 'Name', 'City','Age'. Now I want to select only the name column from the dataframe and print it. How can I do it?
May 9 in Python by Esha
8 views

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
0 votes

Pandas allows you to index the dataframe so you can use the column name to print the column. For your requirement, you want to print only the name column. You can do this as follows:

print(df['Name'])
answered May 9 by Suman

Related Questions In Python

0 votes
1 answer

How to convert a Pandas GroupBy object to DataFrame in Python

g1 here is a DataFrame. It has a hierarchical index, ...READ MORE

answered Nov 12, 2018 in Python by Nymeria
• 3,500 points
2,328 views
0 votes
1 answer

How to use Pandas HDF5 as a Database in Python?

HDF5 works fine for concurrent read only ...READ MORE

answered Nov 30, 2018 in Python by Nymeria
• 3,500 points

edited Dec 10, 2018 by Nymeria 47 views
0 votes
0 answers

How to implement multiple try codes in a single block using Python?

Hi all, As per the title, I am ...READ MORE

Jan 14 in Python by Anirudh
• 2,050 points
18 views
0 votes
1 answer

How to merge two dictionaries in a single expression?

In Python 3.5 or greater: z = {**x, ...READ MORE

answered Mar 12 in Python by Trisha
38 views
0 votes
1 answer

how can i count the items in a list?

suppose you have a list a = [0,1,2,3,4,5,6,7,8,9,10] now ...READ MORE

answered May 2 in Python by Mohammad
• 920 points
19 views
+4 votes
6 answers
0 votes
1 answer

How to replace entire column in pandas dataframe?

Use the dataframe with respective column names ...READ MORE

answered May 8 in Python by John
7 views
+2 votes
2 answers

How can I replace values with 'none' in a dataframe using pandas

Actually in later versions of pandas this ...READ MORE

answered Aug 13, 2018 in Python by bug_seeker
• 14,960 points
2,375 views

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.