Get all columns from a DataFrame

Python built-in function list returns the columns of Pandas DataFrame.

import pandas

a = [
    ('Texas', 29),
    ('New York', 19),
    ('California', 40),
    ('Florida', 21),
]

df = pandas.DataFrame(a, columns=['State', 'Population'])

print(df)
#         State  Population
# 0       Texas          29
# 1    New York          19
# 2  California          40
# 3     Florida          21

columns = list(df)

print(columns)  # ['State', 'Population']

pandas DataFrame

pandas tutorial