Python
#15

Sort DataFrames by Multiple Columns in Mixed Directions in Pandas

Easy
Interview 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
namedepartmentsalary
AaravAnalytics85000
BhavnaAnalytics95000
ChiragEngineering90000
Expected Output Structure3 rows
namedepartmentsalary
BhavnaAnalytics95000
AaravAnalytics85000
ChiragEngineering90000
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