access columns with specific names in pandas code example
Example 1: select specific column names from dataframe
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
Example 2: python pandas return column name of a specific column
# Basic syntax:
list(df.columns)[column_number]
# This returns the column name of the column of interest