我的数据包含变量 participants、origin 和 score。我想要那些得分大于 60 的参与者和来源。这意味着要过滤参与者,我必须考虑来源和分数。我可以仅根据原点或分数进行过滤,但它不起作用。
如果有人能帮助我,那就太好了!!!
请您参考如下方法:
我想你可以使用 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
