Answers for "dataframe multiindex"

0

dataframe multiindex

multi = df.set_index(['Film', 'Chapter', 'Race', 'Character'])
Posted by: Guest on September-28-2021
-1

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
Posted by: Guest on May-10-2021

Python Answers by Framework

Browse Popular Code Answers by Language