简体   繁体   English

如何使用python考虑其他两个变量对一个变量应用过滤器

[英]how to apply filter on one variable considering other two variable using python

I am having data with variables participants , origin , and score .我的数据包含变量participantsoriginscore And I want those participants and origin whose score is greater than 60 .我想要那些得分greater than 60参与者和来源。 That means to filter participants I have to consider origin and score.这意味着过滤参与者我必须考虑来源和分数。 I can filter only on origin or only on score but it will not work.我只能根据原点或分数进行过滤,但它不起作用。

If anyone can help me, its great!!!如果有人可以帮助我,那就太好了!!!

I think you can use boolean indexing :我认为您可以使用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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在Python中设置一个变量大于另一个变量? - How to set that one variable is greater then the other in Python? 对一个变量使用两个单独的循环 - python - Using two separate loops for one variable - python 如何将方法应用于存储在 python 中其他文件中的变量? - how to apply a method to a variable stored in other file in python? 如何通过在Python中的一个位置替换另一个变量的字母来编写变量? - How to write a variable by replacing the letter of an other variable by one place in Python? 如何获得非线性多元回归的方程,其中一个变量依赖于python中的其他两个独立变量 - how to get equation for nonlinear mutivariate regression in which one variable is dependent on other two independent variables in python 如何将变量从一个python脚本传递给另一个python脚本? - How to pass a variable from one python script to an other one? 在 Python 中使用 xarray 的其他两个变量扩展变量的坐标 - Expanding coordinates of a variable using other two variables of xarray in Python 一变量二值Python - One variable two values Python 使用其他变量将变量添加到python函数 - adding variable to python function using other variable 如何使用另一个 Python 返回变量 - How to return a variable using another one Python
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM