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

Slicing using the [ ] operator

Slicing a DataFrame across its index is syntactically identical to performing the same operation with a Series. Because of this, we will not go into the details of the various permutations of slices in this section and only look at a few representative examples applied to a DataFrame.

When slicing using the [] operator, the slice is performed across the index and not the columns. The following retrieves the first five rows:

And the following returns rows starting with the ABT label through the ACN labels:

Slicing ...

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