Back to Practice
#0039
Filter Active High-Value Users
EasyPandas12 min10 XP
Problem
Given a DataFrame with user_id, is_active, and spend columns, return only active users whose spend is at least 100.
Why This Matters
Most dataframe work starts with "which rows do I actually want?" This problem builds the habit of writing readable masks.
Function Signature
def active_high_value_users(df):
Examples
Example 1
Inputusers: active/spend rows [(1, True, 120), (2, False, 200), (3, True, 80)]
Outputuser 1 only
User 2 spends enough but is inactive. User 3 is active but spends too little.
Constraints
- Return only user_id and spend columns.
- Reset the index in the returned DataFrame.
- Do not mutate the original DataFrame.
CodePython
Visible browser tests run here when available.
Testcases1 visible / 4 hidden categories
Two conditions
Inputactive users and spend values
Expectedonly users satisfying both conditions
Both conditions must be true for a row to remain.
Hidden Test Categories
No matching rowsAll rows matchSpend exactly 100Original index not starting at zero