O'Reilly logo

Learning pandas - Second Edition by Michael Heydt

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Selecting rows using Boolean selection

Rows can be selected by using Boolean selection. When applied to a data frame, a Boolean selection can utilize data from multiple columns. Consider the following query, which identifies all stocks with a price less than 100:

This result can then be applied to the DataFrame using the [] operator to return only the rows where the result was True:

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:

It is common ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required