📅  最后修改于: 2022-03-11 14:46:08.881000             🧑  作者: Mango
>>> df
row col grumpiness
0 5 0 0.846412
1 0 1 0.703981
2 3 1 0.212358
3 0 2 0.101585
4 5 1 0.424694
5 5 2 0.473286
>>> df.pivot_table('grumpiness', 'row', 'col', fill_value=0)
col 0 1 2
row
0 0.000000 0.703981 0.101585
3 0.000000 0.212358 0.000000
5 0.846412 0.424694 0.473286