📅  最后修改于: 2022-03-11 14:45:58.535000             🧑  作者: Mango
df1 = df.set_index(['number','class']).unstack().swaplevel(0,1,1).sort_index(1)
print (df1)
class A B
english math english math
number
1 40 90 87 67
2 21 20 89 89
3 68 50 54 79
4 89 30 21 45
5 90 57 23 23