Average Salary by Department
You're on the People Ops team at Kestrel Labs, a ten-person analytics company. Pay-band review season has opened, and the head of People is costing a proposed new pay floor: for each department, what does a typical salary look like among the people who are already sitting at or above the floor? Several floors get costed before one of them is chosen, so the figure comes with the request.
There is no department table to lean on here. department is a plain label repeated on every employee row, and the teams are different sizes — so one company-wide average would flatten exactly the differences the review exists to look at.
employees_df — one row per employee. salary is annual, in dollars. manager is the name of the person they report to, or None where nobody is recorded.
| 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 floor under discussion, a whole number of dollars.
Task: Print a Python dict whose keys are department names and whose values are the average salary in that department, counting only the people paid at or above the floor that arrives, rounded to 2 decimals. Somebody paid exactly the floor counts. A department where nobody clears the floor drops out of the dict altogether, and if nobody in the company clears it, print an empty dict.
Example: if one team's remaining people averaged eighty thousand dollars and fifty cents, that team's entry would read 'Ops': 80000.5.
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