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
105 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 in Python by Niroj
• 56,800 points
70 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,520 points
21,244 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,520 points

edited Dec 10, 2018 by Nymeria 251 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
92 views
+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 6, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 1,343 views
0 votes
0 answers
+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, 2019 in Python by John
3,991 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
4,126 views