导语:
本文主要介绍了关于python中filter()的多种筛选的相关知识,包括python筛选函数,以及python import这些编程知识,希望对大家有参考作用。
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
"""
本文教程操作环境:windows7系统、Python 3.9.1,DELL G3电脑。
本文为原创文章,版权归知行编程网所有,欢迎分享本文,转载请保留出处!
你可能也喜欢
- ♥ python GIL锁底层原理研究12/01
- ♥ python安装后无法使用是什么原因10/07
- ♥ 如何在python中安装jieba库08/11
- ♥ urlretrieve如何在python中获取远程文件?11/07
- ♥ 如何在python3中比较字符串是否相等09/29
- ♥ 如何在 Python 中输出单引号?08/31
内容反馈