📣 Introducing $2.95/Hr H100, H200, B200s, and B300s: train, fine-tune, and scale ML models affordably, without having to DIY the infrastructure   📣 Run Saturn Cloud on AWS, GCP, Azure, Nebius, Crusoe, or on-prem. 📣 Introducing $2.95/Hr H100, H200, B200s, and B300s: train, fine-tune, and scale ML models affordably, without having to DIY the infrastructure   📣 Run Saturn Cloud on AWS, GCP, Azure, Nebius, Crusoe, or on-prem. 📣 Introducing $2.95/Hr H100, H200, B200s, and B300s: train, fine-tune, and scale ML models affordably, without having to DIY the infrastructure   📣 Run Saturn Cloud on AWS, GCP, Azure, Nebius, Crusoe, or on-prem.
← Back to Blog

How to get a list of column names from a Pandas DataFrame

Learn how to return a list of column headers in Pandas

How to get a list of column names from a Pandas DataFrame

Pandas makes it easy to obtain a list of column names from a DataFrame. For an extremely concise solution, you can simply call list() on your DataFrame object, which will return a list of header names:

import pandas as pd

data = pd.DataFrame({'a': [1, 2, 3, 4, 5], 'b': [10, 20, 30, 40, 50]})

list(data)

There are also two built-in tolist() methods for Index objects. If performance is a priority, the first method listed below is faster than the second, but either works:

#faster option
data.columns.values.tolist()

data.columns.tolist()

You can swap also out the Pandas values call for NumPy’s to_numpy instead; this method is preferred for clarity.

data.columns.to_numpy().tolist()

Finally, if you are using Python 3.5+, you can use unpacking generalizations to return a list of column names. This class of operations also includes ways to output your column names as a tuple or set, if so desired. Here’s how to do it for a list (yes, it’s that quick and easy!):

[*data]

In summary, in Python 3.5 and beyond, iterable unpacking operators provide the most concise way to get a list of column names from a DataFrame. For previous versions of Python, and where conciseness is preferred, list() is an alternative. If performance is a priority columns.values.tolist() (or its NumPy equivalent) is usually the fastest option.

Additional Resources:

Keep reading

Related articles

How to get a list of column names from a Pandas DataFrame
Dec 11, 2025

Choosing an MLOps Platform in 2026

How to get a list of column names from a Pandas DataFrame
Dec 10, 2025

SageMaker vs. Saturn Cloud: Which One Is Better for Your Team?

How to get a list of column names from a Pandas DataFrame
Dec 1, 2025

Production Inference at Scale with Saturn Cloud & Nebius Token Factory