这是我的数据框“dfm”:
match org_o group
012 012 Smile Communications 92
012 012 Smile 92
10types 10TYPES 93
10types 10types.com 93
360works 360WORKS 94
360works 360works.com 94
400 IBM AS/400 Division 36
6c f3f IBM Internal US Division 36
我想选择具有相同“组”编号和相同“匹配”的行。结果如下:
match org_o group
012 012 Smile Communications 92
012 012 Smile 92
10types 10TYPES 93
10types 10types.com 93
360works 360WORKS 94
360works 360works.com 94
有人知道我在大熊猫蟒蛇身上怎么做吗?
最佳答案
对“组”和“匹配”执行groupby
,然后对“组织”1的计数执行filter
:
In [245]:
df.groupby(['group', 'match']).filter(lambda x: x['org_o'].count() > 1)
Out[245]:
match org_o group
0 012 012 Smile Communications 92
1 012 012 Smile 92
2 10types 10TYPES 93
3 10types 10types.com 93
4 360works 360WORKS 94
5 360works 360works.com 94