說我們有一個數據幀,看起來像這樣:如何旋轉大熊貓數據幀
day_of_week ice_cream count proportion
0 Friday vanilla 638 0.094473
1 Friday chocolate 2048 0.663506
2 Friday strawberry 4088 0.251021
3 Monday vanilla 448 0.079736
4 Monday chocolate 2332 0.691437
5 Monday strawberry 441 0.228828
6 Saturday vanilla 24 0.073350
7 Saturday chocolate 244 0.712930 ... ...
我想要一個新的數據幀坍塌到day_of_week
作爲索引,所以它看起來是這樣的:
day_of_week vanilla chocolate strawberry
0 Friday 0.094473 0.663506 0.251021
1 Monday 0.079736 0.691437 0.228828
2 Saturday ... ... ...
我可以實現這個最乾淨的方式是什麼?
查找樞軸功能上大熊貓 – lordingtar