需要一些帮助,让uniqued值从熊猫数据框中熊猫数据框中唯一值
我有:
>>> df1
source target metric
0 acc1.yyy acx1.xxx 10000
1 acx1.xxx acc1.yyy 10000
的目标是消除基于源+目标或目标+源唯一值。但我不能用drop_duplicates获得这个。
>>> df2 = df1.drop_duplicates(subset=['source','target'])
>>> df2
source target metric
0 acc1.yyy acx1.xxx 10000
1 acx1.xxx acc1.yyy 10000
[更新]
也许重复的不正确的单词在这里,所以让我上面解释进一步
id source target
0 bng1.xxx.00 bdr2.xxx.00
1 bng1.xxx.00 bdr1.xxx.00
2 bdr3.yyy.00 bdr3.xxx.00
3 bdr3.xxx.00 bdr3.yyy.00
4 bdr2.xxx.00 bng1.xxx.00
5 bdr1.xxx.00 bng1.xxx.00
,我想删除拥有为例源=目标entryies和target = source。
0 and 4 = same pair
1 and 5 = same pair
2 and 3 = same pair
end goal will be to keep 0 1 2 or 4 5 3 .
不明白你想要做什么。请澄清“基于源+目标或目标+源删除唯一值”。输入和输出的例子会有所帮助。 – Denziloe
我需要采用acc1.yyy + acx1.xxx对,并确保没有与匹配acx1.xxx + acc1.yyy对的OR匹配的条目。 – Cmarv
公制列的情况如何?如果有重复,应使用哪个值?再次,请编辑您的问题以包含示例输入和您想要的输出。 – Denziloe