(20210129已解决)Pandas通过某列值包含特定字符串过滤行
发布日期:2021-05-07 14:24:30 浏览次数:19 分类:技术文章

本文共 297 字,大约阅读时间需要 1 分钟。

  • Overview

    Maybe expressed with english by:

    how to filter rows containing a string pattern from a Pandas dataframe?

  • 问题解析

    只保留某些行,其中某列包含特定的字符串。

  • 解决方案

    df[df['col_name'].str.contains('str_pattern')]

    如果包含多种str_pattern:

    df[df['col_name'].str.contains('sp1') | df['col_name'].str.contains('sp2')]
  • References

上一篇:理解Raft日志||Paxos
下一篇:(20210128已解决)WSL2开机启动cron

发表评论

最新留言

感谢大佬
[***.8.128.20]2025年03月18日 15时58分34秒