【问题标题】:python .loc with some condition(string, regex etc)python .loc 有一些条件(字符串,正则表达式等)
【发布时间】:2016-09-28 04:36:10
【问题描述】:

我愿意获取数据框的子集。条件是,某列的值以字符串“HOUS”开头。我应该怎么做?。

df.loc[df.id.startswith('HOUS')]

【问题讨论】:

    标签: python pandas dataframe substring


    【解决方案1】:

    我应该搜索更多。

    这是解决方案。

    df[df.id.str.startswith('HOUS')]
    

    【讨论】:

      猜你喜欢
      • 2012-08-28
      • 1970-01-01
      • 2017-12-23
      • 2022-06-10
      • 1970-01-01
      • 2019-08-17
      • 1970-01-01
      • 2019-10-17
      • 1970-01-01
      相关资源
      最近更新 更多