减去重复行熊猫的值

时间:2019-09-23 14:17:51

标签: python pandas

我有以下数据框:

Date         Code     Name             Days
23/09/2019   WO       Smith Thomas     1
23/09/2019   RE       Johnson Robert   1
24/09/2019   WO       Smith Thomas     1
24/09/2019   NW       Smith Thomas     0.5
25/09/2019   OP       Johnson Robert   0.5
25/09/2019   GF       Johnson Robert   0.5

如果基于日期和名称列重复,我想检查天数总和是否大于1。 如果是,那么我想与其他人一起获得最大价值,但不要删除任何行,否则什么也不做。

所需的输出为:

Date         Code     Name             Days
23/09/2019   WO       Smith Thomas     1
23/09/2019   RE       Johnson Robert   1
24/09/2019   WO       Smith Thomas     0.5
24/09/2019   NW       Smith Thomas     0.5
25/09/2019   OP       Johnson Robert   0.5
25/09/2019   GF       Johnson Robert   0.5

有什么熊猫方法吗?

我可以循环使用Python,但效率似乎不高

谢谢

0 个答案:

没有答案