O'Reilly logo

Learning pandas - Second Edition by Michael Heydt

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

Grouping using index levels

It is possible to group by using the values in the index instead of the columns. The sensor data is well suited for a hierarchical index, which can be used to demonstrate this concept. Let's set up a form of this data with a hierarchical index consisting of the sensor and axis columns:

Grouping can now be performed using the various levels of the hierarchical index. This code will group by index level 0 (the sensor names):

Grouping by multiple levels can be performed by passing the levels in a list. And if MultiIndex ...

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