Filtering based on multiple conditions – AND

Now, let's look at some techniques to filter the data using multiple criteria or conditions. First, we select those rows that have values for prices higher than 1,000,000, and for which the State parameter is New York (NY), as shown here:

data[(data['Zhvi'] > 1000000) & (data['State'] == 'NY')].head()

Pass the preceding multi-condition to the database's DataFrame. In the following screenshot, this technique has selected only those rows where the price value is higher than 1,000,000, and State is New York, and has filtered out all the other records:

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.