O'Reilly logo

Hands-On Data Analysis with NumPy and pandas by Curtis Miller

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Hierarchical indexing

We have come a long way, but we're not quite done yet. We need to talk about hierarchical indexing. In this section, we look at hierarchical indices, why they are useful, how they are created, and how they can be used.

So, what are hierarchical indices? They bring additional structure to an index and exist in pandas as MultiIndex class objects, but they are still an index that can be assigned to a series or DataFrame. With a hierarchical index, we think of rows in a DataFrame, or elements in a series, as uniquely identified by combinations of two or more indices. These indices have a hierarchy, and selecting an index at one level will select all elements with that level of the index. We can go on a more theoretical path ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required