October 2019
Beginner to intermediate
674 pages
16h 43m
English
Slicing by supplying the start and end position to subset a range of values can be done in pandas objects, just as in NumPy arrays. The [ : ] operator helps in range slicing.
Let's slice the Series that we created earlier to subset the second, third, and fourth rows:
ser[1:4]
This results in the following output:

As always with a range in Python, the value after the colon is excluded when slicing.
Range slicing can be done by providing either the start or end index. If the end index is not provided, values are sliced from the given starting index to the end of the data structure. Likewise, ...
Read now
Unlock full access