选择等于python中子字符串的列 [英] Selecting columns equal to a substring in python

查看:65
本文介绍了选择等于python中子字符串的列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  1. clients4.google.com
  2. m.facebook.com
  3. static.ak.fbcdn.net
  4. static.ak.fbcdn.net
  5. static.ak.fbcdn.net

我想选择子字符串fb可用的所有行. 在熊猫数据框中

I want to select all the rows where the substring fb is available. In pandas dataframe

推荐答案

您可以使用StringMethods.contains:

>>> df = pd.read_clipboard(header=None)
>>> df[df[0].str.contains('fb')]
                     0
2  static.ak.fbcdn.net
3  static.ak.fbcdn.net
4  static.ak.fbcdn.net

这篇关于选择等于python中子字符串的列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆