1In [28]:
2
3filter_col = [col for col in df if col.startswith('foo')]
4filter_col
5Out[28]:
6['foo.aa', 'foo.bars', 'foo.fighters', 'foo.fox', 'foo.manchu']
7In [29]:
8
9df[filter_col]
10Out[29]:
11 foo.aa foo.bars foo.fighters foo.fox foo.manchu
120 1.0 0 0 2 NA
131 2.1 0 1 4 0
142 NaN 0 NaN 1 0
153 4.7 0 0 0 0
164 5.6 0 0 0 0
175 6.8 1 0 5 0
18