美文网首页我爱编程
pandas.DataFrame.filter

pandas.DataFrame.filter

作者: Mrcwx | 来源:发表于2018-05-16 21:38 被阅读0次

    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
    

    相关文章

      网友评论

        本文标题:pandas.DataFrame.filter

        本文链接:https://www.haomeiwen.com/subject/mvbmdftx.html