python中filter()的多种筛选

558次阅读
没有评论

python中filter()的多种筛选

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
"""
神龙|纯净稳定代理IP免费测试>>>>>>>>天启|企业级代理IP免费测试>>>>>>>>IPIPGO|全球住宅代理IP免费测试

相关文章:

版权声明:wuyou2022-03-18发表,共计311字。
新手QQ群:570568346,欢迎进群讨论 Python51学习