Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Introduction
Series
What DataFrames are
DataFrame columns
DataFrame rows
Filtering rows and columns
22. Filtering rows by index
Filtering data frames
Sorting rows
Summary

Instruction

Great! You can filter rows in a DataFrame using the index slice notation as with lists. In slice notation, you give the start index, a colon (:), and the end index. The start index is inclusive; the end index isn't. As with lists, indexes start at 0. The following line of code selects the first five rows of the hospitals DataFrame:

hospitals[0:5]

As with lists, you can also provide only the start index. This way you will select only the rows starting from the provided index till the end of the DataFrame:

hospitals[3:]

You can also provide only the end index. This way you will select all rows up to this index (exclusive). The following line of code selects all rows up to the seventh row (mind that we are counting from zero):

hospitals[:7]

Exercise

Now it's your turn. From the eu_states DataFrame, show the rows from 3rd to 10th row.