Complete the code to filter rows where the 'age' column is greater than 30 using query().
filtered = df.query('age [1] 30')
The query() method uses a string expression to filter rows. To select rows where 'age' is greater than 30, use 'age > 30'.
Complete the code to filter rows where the 'score' column is equal to 100 using query().
perfect_scores = df.query('score [1] 100')
To filter rows where 'score' equals 100, use the equality operator '=='.
Fix the error in the query to select rows where 'height' is less than or equal to 170.
short_people = df.query('height [1] 170')
The correct operator for 'less than or equal to' is '<='. The option '=>' is invalid syntax.
Fill both blanks to filter rows where 'age' is greater than 25 and 'score' is less than 80 using query().
filtered = df.query('age [1] 25 and score [2] 80')
To filter rows where 'age' is greater than 25 and 'score' is less than 80, use 'age > 25 and score < 80'.
Fill all three blanks to create a dictionary comprehension that maps each 'name' to their 'score' only if 'score' is greater than 50 using query() filtering.
result = {row['[1]']: row['[2]'] for _, row in df.query('[3]').iterrows()}The dictionary comprehension uses 'name' as keys and 'score' as values. The query filters rows where 'score' is greater than 50.