Pandas multi-index: Working with 3D data using `.loc` and `.xs`

Pandas multi-index: Working with 3D data using `.loc` and `.xs`

My students used to ask if Python Pandas supports 3D data structures.

Answer: No. Series are 1D and data frames are 2D.

But… a multi-index effectively gives you more dimensions. You can then navigate the indexes with .loc and .xs.