[英]how to apply filter on one variable considering other two variable using python
我的數據包含變量participants
、 origin
和score
。 我想要那些得分greater than 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
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.