我有一个包含3列的数据框。列具有非唯一值,但整个行都是唯一的。
+------------------------------+
| ID TYPE Value |
+------------------------------+
| 0 u1234 Beds 12.0 |
| 1 u1234 Floors 2.0 |
| 2 u1111 Beds 30.0 |
| 3 u1111 Floors 10.0 |
| 4 u1111 LandArea 1000.23 |
| 5 u1000 Beds 3.0 |
| 6 u1000 Power 240/24 |
| 7 u1555 Power 330/33 |
+------------------------------+
我想这样重塑列
+----------------------------------------------+
| ID Beds Floors LandArea Power |
+-----------------------------------------------
| 0 u1234 12 2 0 0 |
| 1 u1111 30 10 1000.23 0 |
| 2 u1000 3 0 0 240/24 |
| 3 u1555 0 0 0 330/33 |
+----------------------------------------------+
I am unable to do the same with pivot table as the value column contains non numeric values.