【发布时间】:2021-07-30 02:52:19
【问题描述】:
原始数据:
| Sales | Product | Qty |
|---|---|---|
| James | apple | 10 |
| Johnson | apple | 1 |
| Jessie | banana | 2 |
| Judy | melon | 5 |
| James | melon | 5 |
| Jessie | apple | 8 |
收件人:
| Sales | Apple | Melon | Banana | Total |
|---|---|---|---|---|
| James | 10 | 5 | 0 | 15 |
| Judy | 0 | 5 | 0 | 5 |
| Jessie | 8 | 0 | 2 | 10 |
| Johnson | 1 | 0 | 0 | 1 |
我想用 pandas 计算每个产品和每个销售额的数量,那么 pandas 怎么做呢?
【问题讨论】:
-
我刚刚使用了 pivot_table 来完成这项工作