# 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
# Basic syntax:
list(df.columns)[column_number]
# This returns the column name of the column of interest
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)