Python
#20

Dynamic String Filtering with DataFrame.query() in Pandas

Medium
Interview Question #20

Use `df.query()` to filter rows where `status == 'Active'`, `age > 25`, and `salary` exceeds a dynamic Python variable `min_salary = 75000`.

Input Table: candidates
3 rows preview
namestatusagesalary
SachinActive2785000
RahulActive2380000
PoojaInactive3095000
Expected Output Structure1 rows
namesalary
Sachin85000
Interview Context

Asked frequently in data analyst and business analyst technical rounds. Focus on clean filtering, optimal indexing usage, and unambiguous column selection.

Python 3.10 (Pandas)
Environment Ready

Click "Run & Test" to execute your Pandas code against the test assertions.

Chat with us