How to Get the List of Column Names or Headers in Pandas

Spread the love

Problem –

You have a pandas dataframe and you want to get the list of column names or headers in pandas.

Solution –

Let’s read a dataset to illustrate.

import pandas as pd

df = pd.read_csv('')

In Pandas, the dataframe.columns attribute gives you the names of the columns in a pandas dataframe. And to convert it into a list you can use tolist() method.


You can also write


Or simply


All of the methods works.

Rating: 1 out of 5.

Leave a Reply