Python
All Top Python Interview Questions#15
Sort DataFrames by Multiple Columns in Mixed Directions in Pandas
EasyInterview Question #15
Given an `employee_df`, sort by `department` alphabetically ascending, and within each department sort by `salary` descending. Place employees with missing salaries at the end.
Input Table: employee_df
3 rows preview| name | department | salary |
|---|---|---|
| Aarav | Analytics | 85000 |
| Bhavna | Analytics | 95000 |
| Chirag | Engineering | 90000 |
Expected Output Structure3 rows
| name | department | salary |
|---|---|---|
| Bhavna | Analytics | 95000 |
| Aarav | Analytics | 85000 |
| Chirag | Engineering | 90000 |
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)…