This article is part of a series of practical guides for using the Python data processing library pandas. To see view all the available parts, click here.
In other sections in this series, we’ve looked at how we can use booleans (a value that is either True
or False
) in pandas. Specifically, we’ve looked at how a list or array of booleans can be used to filter a DataFrame. In those examples we generated lists of booleans using simple comparisons like “are the values in the fixed acidity
column > 12?” However, simple comparisons like this are only one of many ways we can create booleans. In this guide we are going to look at a range of methods that allow us to do more complex comparisons, while also making our code more concise and easier to understand.