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.