【问题标题】:how to apply filter on one variable considering other two variable using python如何使用python考虑其他两个变量对一个变量应用过滤器
【发布时间】:2017-01-31 00:22:51
【问题描述】:

我的数据包含变量 participantsoriginscore。我想要那些得分为greater than 60 的参与者和来源。这意味着过滤参与者我必须考虑来源和分数。我只能根据来源或分数进行过滤,但它不起作用。

如果有人可以帮助我,那就太好了!!!

【问题讨论】:

  • 请分享您的数据样本和您迄今为止编写的代码

标签: python pandas indexing conditional-statements tableau-api


【解决方案1】:

我觉得你可以用boolean indexing:

df = pd.DataFrame({'participants':['a','s','d'],
                   'origin':['f','g','t'],
                   'score':[7,80,9]})

print (df)
  origin participants  score
0      f            a      7
1      g            s     80
2      t            d      9

df = df[df.score > 60]
print (df)
  origin participants  score
1      g            s     80

【讨论】:

  • 如果我的回答有帮助,别忘了accept。谢谢。
猜你喜欢
  • 2011-02-26
  • 1970-01-01
  • 1970-01-01
  • 2013-10-21
  • 2023-04-07
  • 2017-10-13
  • 1970-01-01
  • 1970-01-01
  • 2021-02-10
相关资源
最近更新 更多