簡體   English   中英

如何使用python考慮其他兩個變量對一個變量應用過濾器

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

我的數據包含變量participantsoriginscore 我想要那些得分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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM