![](/img/trans.png)
[英]Assign unique identifier for dataframe rows based on dataframe with preassigned unique identifier
[英]Remove rows in dataframe based on value counts of unique identifier
Identifier Value_1 Value_2 Value_3
123 20. 30. 1
123. 12. 14. 1
123. 18. 12. 1
124. 12. 10. 6
124. 12. 16. 1
...
321. 14. 20. 3
Size 871 x 24
你好。 我有一個大小為 871 x 24 的數據框/問卷。dataframe 由許多參與者做出的問卷答案組成,每個參與者在“標識符”列中都有一個唯一的 ID。 我希望能夠僅過濾從總數 dataframe 中做出 10 次或更多響應的參與者,到目前為止,我已經設法過濾出符合以下條件的 ID:通過使用:
df['Identifier'].value_counts()>=10
但是我如何從總數 dataframe 中刪除它們並創建一個包含其他列和值的新的仍然?
將Series.map
與boolean indexing
一起使用:
df[df['Identifier'].map(df['Identifier'].value_counts())>=10]
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.