【发布时间】:2016-04-29 03:51:11
【问题描述】:
我在 Py pandas 中有以下 DataFrame
source target value type
0 10 1200 0.500 Undirected
1 13 3333 0.600 Undirected
2 10 1200 0.500 Undirected
3 15 2300 0.350 Undirected
4 18 5300 0.250 Undirected
5 17 2300 0.100 Undirected
6 13 3333 0.600 Undirected
- 我喜欢删除重复的每一行(出现两次或 更多的)。在这种情况下,具有 Index 0 和 Index 2 的行和 Index 1 和 Index 6 应被识别为重复项,以便我们只保留其中一个条目。
- 如何显示源和目标的重复项?我喜欢交叉检查“价值”是否真的总是相同的。
【问题讨论】:
-
只需使用
.drop_duplicates()和.duplicated()
标签: python pandas dataframe duplicates