Selecting values from a range of rows and all columns

Here, we will use loc method to view the values from a range of rows and columns. To achieve this, the first parameter for the loc method is the range index of rows to be selected. Since we want values from all columns, we pass a colon (:) as the second parameter, as follows:

zillow.loc[201:205, :] 

The output can be seen in the following screenshot:

Selecting non-contiguous rows also works in a similar way. In the non-contiguous rows method, we pass row indices as a list to the loc method, as seen in the following code:

zillow.loc[[0,5,10], :]  

And the output would be as follows:

Let's ...

Get Mastering Exploratory Analysis with pandas now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.