All problems

Salary Rank Within Department

mediumPythonGroupByRanking

You're a data analyst at Kestrel Robotics, building an internal pay-transparency tool. Every employee will be shown where they stand against their own department rather than against the whole company, because comparing an engineer's salary to a marketer's tells nobody anything useful.

The department leads are reviewing their teams' pages one at a time before the tool goes live, and each of them wants the same line confirmed by hand before signing off: who does the tool say is the highest-paid person on this team? Whichever team is up that morning is the one the report has to answer for. Names and salaries sit in the same table, so the difficulty is not finding the figure — it is coming back with the person attached to it.

employees_df — one row per employee. salary is annual, in dollars. manager is None for anyone who reports to nobody in this table.

id name department salary hire_date manager
1 Ava Chen Engineering 145000 2021-03-14 None
2 Ben Ortiz Engineering 118000 2022-06-01 Ava Chen
3 Cara Novak Engineering 121000 2023-01-10 Ava Chen
4 Deshawn Lee Sales 95000 2020-09-23 None
5 Elin Kask Sales 88000 2022-11-05 Deshawn Lee
6 Farid Amiri Marketing 76000 2023-04-18 None
7 Grace Kim Data 132000 2021-07-30 None
8 Hugo Silva Data 110000 2023-02-14 Grace Kim
9 Ines Duarte Data 104000 2023-08-01 Grace Kim
10 Jonas Weber Sales 91000 2021-12-19 Deshawn Lee

Input

The DataFrame above is already built for you — the employee rows are not read from input. What does arrive is a single line holding the department under review, spelled exactly as it appears in the department column.

Task: Print the name of the highest-paid employee in that department, as a bare string — no quotes, no brackets. If two people in it were tied at the top, print whichever of them appears earlier in the table. Every department named in the table has at least one employee, so there is always somebody to name — including the one-person department, whose only employee is also its highest paid.

Example: if the top earner on the team under review were called Kai Mensah, you'd print Kai Mensah.

Sign in to solve this problem

Reading problems is free for everyone — solving them (Run, Submit, and tracking what you've solved) needs an account.

Sign in

Discussion

Sign in to join the discussion — reading is open to everyone.

Loading comments…