Recall & Review
beginner
What is Boolean indexing in data analysis?
Boolean indexing is a way to select data from a dataset using True or False values. It helps to filter rows or elements that meet a condition.
Click to reveal answer
beginner
How do you create a Boolean mask in Python with pandas?
You create a Boolean mask by writing a condition on a DataFrame or Series, like df['age'] > 30. This returns True for rows where age is over 30, and False otherwise.
Click to reveal answer
beginner
Example: What does df[df['score'] >= 70] do?
It selects all rows from df where the 'score' column is 70 or higher. This filters the data to only include those rows.
Click to reveal answer
intermediate
Can Boolean indexing be combined with multiple conditions?
Yes! You can combine conditions using & (and), | (or), and ~ (not) with parentheses. For example, df[(df['age'] > 20) & (df['score'] > 50)] selects rows meeting both conditions.
Click to reveal answer
beginner
Why is Boolean indexing useful in data analysis?
It helps quickly find and work with specific parts of data without changing the original dataset. This makes data cleaning and exploration easier and faster.
Click to reveal answer
What does Boolean indexing return when applied to a DataFrame?
✗ Incorrect
Boolean indexing filters rows based on True/False conditions, returning only rows where the condition is True.
Which symbol is used for the logical AND in Boolean indexing conditions?
✗ Incorrect
In pandas Boolean indexing, & is used for logical AND between conditions.
How do you select rows where the 'age' column is NOT greater than 30?
✗ Incorrect
The ~ operator negates the condition, so ~(df['age'] > 30) selects rows where age is NOT greater than 30.
What will df[(df['score'] > 50) | (df['age'] < 20)] select?
✗ Incorrect
The | operator means OR, so it selects rows where either condition is true.
What type of object is returned when you write df['age'] > 30?
✗ Incorrect
df['age'] > 30 returns a Series of Boolean values indicating which rows meet the condition.
Explain how Boolean indexing works in pandas and give a simple example.
Think about how True/False values help select data.
You got /3 concepts.
Describe how to combine multiple conditions in Boolean indexing and why parentheses are important.
Remember operator precedence and grouping.
You got /3 concepts.