Select only one index of multiindex DataFrame

One way could be to simply rebind df.index to the desired level of the MultiIndex. You can do this by specifying the label name you want to keep:

df.index = df.index.get_level_values('first')

or use the level’s integer value:

df.index = df.index.get_level_values(0)

All other levels of the MultiIndex would disappear here.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)