如何找到每个学生人数都属于独特的学生?
我有一个数据框架和约10-12列。该列之一是学生编号,例如1234567,另一个是标识符,例如护照号码,许可证号。我如何发现每个学生都有一个唯一的标识符。像学生1234567一样,仅具有标识符ABC5679K。我也想存储用重复标识符标记的学生。例如,如果学生1234567也具有标识符ABC3408T,我想知道这些。
I have a data frame and around 10-12 columns. One of the column is the student number e.g. 1234567 and the other is an identifier e.g passport numbers, license number . How can I find that each student has a unique identifier. Like student 1234567 has identifier ABC5679K only. Also I want to store the students who are tagged with duplicate identifier. For e.g. If student 1234567 also has identifier ABC3408T, I want to know those.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
假设第一个学生具有唯一的其他ID,而第二个则具有两个不同的ID:
groupby.transform
nunique
nunique 为此:
您可以使用
,对于所有具有重复其他ID的学生的列表:
输出:
[2]
Assuming such input, where the first student has a unique other id, while the second has two different ids:
you can use
GroupBy.transform
withnunique
for that:output:
Or, for a list of all students with duplicated other ids:
output:
[2]
df.groupby([“ student_name”])[“ passport_number”]。nunique()> 1
您可以使用GroupBy和Nunique功能来帮助您识别重复序列。希望这个回答您的问题。
df.groupby(["student_name"])["passport_number"].nunique() > 1
You can use the groupby and nunique function to help you identify repeats. Hope this answer your question.