I have a multi-index dataset like this:
mean std
Happiness Score Happiness Score
Region
Australia and New Zealand 7.302500 0.020936
Central and Eastern Europe 5.371184 0.578274
Eastern Asia 5.632333 0.502100
Latin America and Caribbean 6.069074 0.728157
Middle East and Northern Africa 5.387879 1.031656
North America 7.227167 0.179331
Southeastern Asia 5.364077 0.882637
Southern Asia 4.590857 0.535978
Sub-Saharan Africa 4.150957 0.584945
Western Europe 6.693000 0.777886
I would like to sort it by standard deviation.
My attempt:
import numpy as np
import pandas as pd
df1.sort_values(by=('Region','std'))
How to fix the problem?
df.columnsfor you?df.columnsgivesMultiIndex(levels=[['mean', 'std'], ['Happiness Score']], labels=[[0, 1], [0, 0]])