在 pandas 数据框中选择唯一的观测值 [英] Selecting unique observations in a pandas data frame
本文介绍了在 pandas 数据框中选择唯一的观测值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个pandas
数据帧,其列为uniqueid
.我想根据此列从数据框中删除所有重复项,以便所有其余观察结果都是唯一的.
I have a pandas
data frame with a column uniqueid
. I would like to remove all duplicates from the data frame based on this column, such that all remaining observations are unique.
推荐答案
There is also the drop_duplicates()
method for any data frame (docs here). You can pass specific columns to drop from as an argument.
df.drop_duplicates(subset='uniqueid', inplace=True)
这篇关于在 pandas 数据框中选择唯一的观测值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文