我有一个数据集,我需要过滤“唯一”事件。基本上,我想删除同一用户一天内多次购买同一产品的每一行,而不管可变设备如何。在多次出现的情况下,我只保留第一行。
数据:
datetime, device, product, user
[
['2013-07-08 15:00:00', 'pc', 'X', 'A'],
['2013-07-09 17:00:00', 'pc', 'X', 'A'],
['2013-07-09 10:00:00', 'andr', 'Y', 'B'],
['2013-07-10 18:00:00', 'pc', 'Y', 'B'],
['2013-07-10 21:00:00', 'ipho', 'Y', 'B'], <- second occurance of B getting Y that day
['2013-07-10 22:00:00', 'andr', 'Y', 'B'], <- third occurance of B getting Y that day
['2013-07-10 02:00:00', 'ipho', 'Z', 'C'],
['2013-07-10 11:00:00', 'pc', 'Z', 'C'] <- second occurance of C getting Z that day
]
应该过滤到:
['2013-07-08 15:00:00', 'pc', 'X', 'A'],
['2013-07-09 17:00:00', 'pc', 'X', 'A'],
['2013-07-09 10:00:00', 'andr', 'Y', 'B'],
['2013-07-10 18:00:00', 'pc', 'Y', 'B'],
['2013-07-10 02:00:00', 'ipho', 'Z', 'C'],
['2013-07-10 11:00:00', 'pc', 'Z', 'C']
我该怎么做呢?