select specific column names from dataframe

Solutions on MaxInterview for select specific column names from dataframe by the best coders in the world

showing results for - "select specific column names from dataframe"
Simone
07 Apr 2019
1import pandas
2data = pandas.DataFrame({'A' : ['X', 'Y'], 
3                        'B' : 1, 
4                        'C' : [2, 3]})
5print data[['A', 'B']]
6
7# Output   A  B
8# 0  X  1
9# 1  Y  1
10