python extract columns from dataframe

description: pandas select columns by name

python select columns from dataframe by name

1
2
3
4
5
6
7
8
9
import pandas 
d = pandas.DataFrame([[1,2,3,4]], columns=['a','b','c','d'])
# d
# a b c d
# 0 1 2 3 4
d2 = d[['b','c']]
# d2
# b c
# 0 2 3

more on search4fan.github.io