Boolean Masks

Learn about the filtration of data using masks and operators.

Introduction to logical mask

To help clean the case study data, we introduce the concept of a logical mask, also known as a Boolean mask. A logical mask is a way to filter an array, or Series, by some condition. For example, we can use the “is equal to” operator in Python, ==, to find all locations of an array that contain a certain value. Other comparisons, such as “greater than” (>), “less than” (<), “greater than or equal to” (>=), and “less than or equal to” (<=), can be used similarly. The output of such a comparison is an array or Series of True/False values, also known as Boolean values. Each element of the output corresponds to an element of the input is True if the condition is met, otherwise it is False.

To illustrate how this works, we will use synthetic data. Synthetic ...