基于这个问题Drop row based on two columns conditions,我有一个看起来像这样的数据框:
df
Data1 Data2
A first
A last
B first
B last
C first
C last
D first
D last
B first
D last
B last
我想消除基于列Data 1和Data 2的数据,条件是删除相同的数据,并删除出现的第三个数据。数据1列中有数据的B和D,这是下一个与数据2列不成对的B和D。我想按顺序保持一对数据1和数据2。
我的预期结果如下:
Data1 Data2
B first
B last
D first
D last
详细信息:
Data1 Data2 Label
A first deleted
A last deleted
B first keep
B last keep
C first deleted
C last deleted
D first keep
D last keep
B first deleted
D last deleted
B last deleted
请原谅我的解释不充分。谢谢。
答案 0 :(得分:1)
这是您需要的吗? struct Task {
let key:String
.....
}
+ duplicated
drop_duplicates