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 ...
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.
Read now
Unlock full access