【发布时间】:2020-07-31 08:35:45
【问题描述】:
我有一个包含如下客户订单数据的数据框:
cust order number order_date total product_id
1 1235846868 2020-01-27 20.0 Product A
1 1235846869 2020-01-27 14.0 Product B
2 1245485221 2020-05-16 11.1 Product B, Product C, Product D
3 1285784226 2020-07-10 24.0 Product D
4 5412151256 2020-03-27 12.0 Product A
4 5412151290 2020-04-13 23.0 Product C, Product B
5 5481581554 2020-02-18 12.0 Product D
正如您在上面看到的,有些客户(例如客户“1”)在同一天多次订购(可能是因为他们在第一次订购时忘记在他们的 basked 中放东西)。我想在同一天汇总客户的这些多个订单,但保留我在数据集中拥有的所有其他列(例如 product_id、order_number 等)。输出表应如下所示:
cust order number order_date total product_id
1 1235846868, 1235846869 2020-01-27 34.0 Product A, Product B
2 1245485221 2020-05-16 11.1 Product B, Product C, Product D
3 1285784226 2020-07-10 24.0 Product D
4 5412151256 2020-03-27 12.0 Product A
4 5412151290 2020-04-13 23.0 Product C, Product B
5 5481581554 2020-02-18 12.0 Product D
谢谢!
【问题讨论】: