Unstacking using hierarchical indexes

To demonstrate unstacking with hierarchical indexes, we will revisit the sensor data we saw earlier in the chapter. However, we will add an additional column to the measurement data that represents readings for multiple users and copy data for two users. The following sets up this data:

With this organization in the data, we can do such things as examine all the readings for a specific person using only the index:

We can also get all the readings of all axes and for all users at interval 1 using .xs() ...

Get Learning pandas - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.