how to create multiindex in pandas code example
Example: pandas df multiindex
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