Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Select title of column with Pandas?

Lets say I have a dataframe:

      Title1     Title2
0       420        50
1       380        40
2       390        45

How can I get as output only the name of the title of the first column (Title1) without the values of the column? I’ve tried iloc but that doesn’t work of course.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

If dfis your dataframe, then the following should work:

first_col = df.columns[0]

See here for more info.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading