# Basic syntax:
your_dataframe.columns
# Note, if you want the column names as a list, just do:
list(your_dataframe.columns)
lst = data.columns.values # data is dataframe
# Import pandas package
import pandas as pd
# making data frame
data = pd.read_csv("nba.csv")
# iterating the columns
for col in data.columns:
print(col)
import pandas
data = pandas.DataFrame({'A' : ['X', 'Y'],
'B' : 1,
'C' : [2, 3]})
print data[['A', 'B']]
# Output A B
# 0 X 1
# 1 Y 1
# Import pandas package
import pandas as pd
# making data frame
data = pd.read_csv("nba.csv")
# iterating the columns
for col in data.columns:
print(col)
# to print the columns
print(df.columns)