Python
All Top Python Interview Questions#20
Dynamic String Filtering with DataFrame.query() in Pandas
MediumInterview 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: df
3 rows preview| name | status | age | salary |
|---|---|---|---|
| Sachin | Active | 27 | 85000 |
| Rahul | Active | 23 | 80000 |
| Pooja | Inactive | 30 | 95000 |
Expected Output Structure1 rows
| name | salary |
|---|---|
| Sachin | 85000 |
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
Starting the real Python + pandas runtime (one-time download)…