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

Subsetting a series

Let's first look at series. Since they are similar to DataFrames, there are key lessons that apply there. The simplest way to subset a series is with square brackets, and we can do so as we would subset a list or NumPy array. The colon operator does work here, but there's more that we can do. We can select elements based on the index of the series, as opposed to just the position of the elements in the series, following many of the same rules as if we were working with integers indicating the position of elements in the series.

The colon operator also works, and largely as expected. Select all elements between two indices:

But unlike working with integer positions, the colon operator does include the endpoint. A particularly ...

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