How to remove levels from a multi-indexed dataframe?
You don't need to create a new DataFrame instance! You can modify the index:
df.index = df.index.droplevel(2)df A1 1 8 3 9
You can also specify negative indices, for selection from the end:
df.index = df.index.droplevel(-1)
If your index has names like
AX Y Z1 1 1 8 3 2 9
Then you can also remove by specifying the index name
df.index = df.index.droplevel(Z)