Click here to Skip to main content
15,902,189 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am currently using pandas and need to list the column titles of a dataframe.

What I have tried:

I have tried using df.columns, where df is dataframe
which gives me
Index([u'A', u'B', u'C'], dtype='object')
.

What I need is ['A', 'B', 'C']
Posted
Updated 26-Jun-17 21:15pm
v2

1 solution

You already have it, the u prefix merely tells you the characters are Unicode. See 2. Built-in Functions — Python 2.7.13 documentation[^].
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900