Skip to Main Content
Hands-On Data Analysis with NumPy and pandas
book

Hands-On Data Analysis with NumPy and pandas

by Curtis Miller
June 2018
Beginner to intermediate content levelBeginner to intermediate
168 pages
3h 40m
English
Packt Publishing
Content preview from Hands-On Data Analysis with NumPy and pandas

Slicing a series with a hierarchical index

When it comes to slicing, series of the hierarchical index resemble NumPy multidimensional arrays. For example, if using the square bracket accessor, we simply separate levels of the hierarchical index with commas, and slice each level, imagining that they were separate indices for separate dimensions of some high-dimensional object. This holds for the loc method as well as for series, but not for DataFrames; we'll see what to do there later. All the usual tricks when slicing indices still work when using loc, but it's easier to get multiple results for a slicing operation.

So, let's see slicing a series of the MultiIndex in action. The first thing we're going to do is slice the first level, selecting ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Hands-On Data Analysis with Pandas

Hands-On Data Analysis with Pandas

Stefanie Molin
Python: End-to-end Data Analysis

Python: End-to-end Data Analysis

Phuong Vothihong, Martin Czygan, Ivan Idris, Magnus Vilhelm Persson, Luiz Felipe Martins
Python: Data Analytics and Visualization

Python: Data Analytics and Visualization

Phuong Vo.T.H, Martin Czygan, Ashish Kumar, Kirthi Raman

Publisher Resources

ISBN: 9781789530797Supplemental Content