Ben Chuanlong Du's Blog

It is never too late to learn.

MultiIndexes in pandas

Multi-Index

In [ ]:
pd.MultiIndex.from_product([[jj.index.name], jj.index.values])

Get Levels

In [ ]:
get_level_values
In [ ]:
it seems to me that there are even easier ways sometimes ...

Extract columns whose 2nd-level index is bi from the data frame df.

In [ ]:
df.loc(axis=1)[:, "bi"]
In [ ]:
 

Comments