使用添加当前值

时间:2018-02-25 08:39:54

标签: python pandas dataframe

我有一个df: production_unit_id | defective_item | defective_item_count | items_produced_count | items_discarded_count

P108 |岩石| 46 | 1 | 315

P108 |剪刀| 47 | 3 | 309

P108 |岩石| 27 | 6 | 315

P085 |剪刀| 50 | 8 | 194

P774 |剪刀| 23 | 146 | 21

P774 |剪刀| 5 | 146 | 21

我希望输出为: production_unit_id | defective_item | defective_item_count | items_produced_count | items_discarded_count

P108 |岩石| 73 | 7 | 630

P108 |剪刀| 47 | 3 | 309

P085 |剪刀| 50 | 8 | 194

P774 |剪刀| 28 | 292 | 42

“defect_item”'列应该分组并且' defective_item_count'应该添加相应的“defect_item'

请帮忙。提前谢谢。

0 个答案:

没有答案