Categories
Python Answers

How to get a list from Pandas DataFrame column headers with Python?

Spread the love

Sometimes, we want to get a list from Pandas DataFrame column headers with Python.

In this article, we’ll look at how to get a list from Pandas DataFrame column headers with Python.

How to get a list from Pandas DataFrame column headers with Python?

To get a list from Pandas DataFrame column headers with Python, we can call list with the data frame object.

For instance, we write

columns = list(my_dataframe)

to call list with the my_dataframe data frame to return a list of column name strings in the data frame.

Conclusion

To get a list from Pandas DataFrame column headers with Python, we can call list with the data frame object.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *