- Select or groupby one column in pandas datafram with multi-level index
To select one column in a datafram with multi-level index, you can use a tuple containing the names of the column in different levels to access desired column.
1
| df1 = df.groupby([('level0','level1')]).sum()
|
- the use of reset_index
Convert index level 0 to a column
1
| df.reset_index(level=0)
|
- Retrieve the index from multi-level index dataframe
1
| df.index.get_level_values(0)
|