midx = pd.MultiIndex(
levels=[["zero", "one"], ["x", "y"]], codes=[[1, 1, 0, 0], [1, 0, 1, 0]]
)
df = pd.DataFrame(np.random.randn(4, 2), index=midx)
df2 = df.groupby(level=0).mean()
df2.reindex(df.index, level=0)
df_aligned, df2_aligned = df.align(df2, level=0)
df[:5].swaplevel(0, 1, axis=0)
df[:5].reorder_levels([1, 0], axis=0)
df.rename(columns={0: "col0", 1: "col1"})
df.rename(index={"one": "two", "y": "z"})
df.rename_axis(index=["abc", "def"])
df.rename_axis(columns="Cols").columns