pandas.DataFrame.filter
2018-05-16 本文已影响0人
Mrcwx
pandas.DataFrame.filter
DataFrame.filter(items=None, like=None, regex=None, axis=None)
参数列表 items=None, like=None, regex=None, axis=None
>>>df
one two three
mouse 1 2 3
rabbit 4 5 6
items对列进行筛选,包含'one', 'three'列选取
>>>df.filter(items=['one', 'three'])
one three
mouse 1 3
rabbit 4 6
filter 对正则表达式进行匹配
>>>df.filter(regex='e$', axis=1)
one three
mouse 1 3
rabbit 4 6
like 对行进行筛选,行名中有bbi选择
df.filter(like='bbi', axis=0)
one two three
rabbit 4 5 6