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, 2019 in Python by Esha
717 views

1 answer to this question.

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, 2019 by Suman

Related Questions In Python

0 votes
1 answer

How to count the NaN values in a column in pandas DataFrame?

Hello @kartik, Lets assume df is a pandas DataFrame. Then, df.isnull().sum(axis = ...READ MORE

answered Jun 15, 2020 in Python by Niroj
• 82,880 points
1,415 views
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,560 points
34,089 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,560 points

edited Dec 10, 2018 by Nymeria 1,043 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, 2019 in Python by Anirudh
• 2,080 points
461 views
0 votes
2 answers
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 7, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 4,070 views
0 votes
1 answer
+5 votes
6 answers

Lowercase in Python

You can simply the built-in function in ...READ MORE

answered Apr 11, 2018 in Python by hemant
• 5,790 points
3,491 views
0 votes
1 answer

How to replace entire column in pandas dataframe?

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

answered May 8, 2019 in Python by John
13,546 views
0 votes
2 answers

How to check if a csv file is empty in pandas?

Try this: df = pd.DataFrame(columns=['Name', 'ID', 'Department']) if df.empty ...READ MORE

answered Jul 1, 2019 in Python by Bob
14,047 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP