Rows can be selected by using Boolean selection. When applied to a DataFrame, a Boolean selection can utilize data from multiple columns.
Selecting rows using Boolean selection
How to do it...
Consider the following query, which identifies all stocks with a price less than 100:
![](https://static.packt-cdn.com/products/9781788291460/graphics/assets/fb1246af-5cce-4dc6-b2c9-14b443a81634.png)
This result can then be applied to the DataFrame using the [] operator to return only the rows where the result was true:
![](https://static.packt-cdn.com/products/9781788291460/graphics/assets/10e70314-d5b1-4ecb-ba54-63ff4fc8cbfb.png)
Multiple conditions can be put together using parentheses. The following retrieves the symbols and price for all stocks with a price between 6 and 10:
![](https://static.packt-cdn.com/products/9781788291460/graphics/assets/049871f2-ae7a-474d-83bc-fd84c70de1f5.png)
It is common to perform selection using multiple variables. The following demonstrates this by finding all rows where the Sector is Health Care and the Price is greater than or...