1、筛选指定的列,类似于花式索引
df2.filter(items=['one','three']) """ one three mouse 1 3 rabbit 4 6 """
2、筛选以字母e结尾的列
df2.filter(regex='e$', axis=1) """ one three mouse 1 3 rabbit 4 6 """
3、筛选以字母e结尾的行
df2.filter(regex='e$',axis=0) """ one two three mouse 1 2 3 """
4、筛选行索引中有bbi的行
df2.filter(like='bbi',axis=0) """ one two three rabbit 4 5 6 """
以上就是python中filter()的多种筛选,希望对大家有所帮助。 更多Python学习指路: python基础教程
本文教程操作环境:windows7系统、Python 3.9.1,DELL G3电脑。
查看更多关于python中filter()的多种筛选的详细内容...
声明:本文来自网络,不代表【好得很程序员自学网】立场,转载请注明出处:http://www.haodehen.cn/did248792