在Python / Pandas

时间:2015-11-17 14:30:56

标签: python pandas

我有以下数据

+------+-------+---------+---------+---------+
| Name | Group | Limit1W | Limit1M | Limit3M |
+------+-------+---------+---------+---------+
| Bob  | A     |     100 |      50 |       0 |
| Bob  | B     |     100 |      50 |       0 |
| Alex | A     |      20 |      50 |       0 |
| Alex | B     |       0 |       0 |       0 |
+------+-------+---------+---------+---------+

我想要

+------+-------+---------+-------+
| Name | Group |  Game   | Limit |
+------+-------+---------+-------+
| Bob  | A     | Limit1W |   100 |
| Bob  | A     | Limit1M |    50 |
| Bob  | A     | Limit3M |     0 |
| Bob  | B     | Limit1W |   100 |
| Bob  | B     | Limit1M |    50 |
| Bob  | B     | Limit3M |     0 |
| Alex | A     | Limit1W |    20 |
| Alex | A     | Limit1M |    50 |
| Alex | A     | Limit3M |     0 |
| Alex | B     | Limit1W |     0 |
| Alex | B     | Limit1M |     0 |
| Alex | B     | Limit3M |     0 |
+------+-------+---------+-------+

我尝试过使用pivot_table,但我一直在努力: typeError只能将列表(而不是“元组”)连接到列表,即使限制只包含数字

0 个答案:

没有答案