Premium problem102. Budget per Assigned Employee

Medium Locked

projects has columns project_id, title and budget. assignments has columns employee_id and project_id.

Return a DataFrame with columns title and budget_per_employee, the budget divided by the number of employees assigned to that project, rounded to the nearest whole number as an integer. Projects with nobody assigned are left out. Sort by budget_per_employee descending then title alphabetically, and renumber the index from 0.

Python's round breaks halves toward even, and so does numpy. Use that behaviour rather than fighting it.

Input

projects =
   project_id   title   budget
0           1   Atlas  30000.0
1           2  Beacon   9000.0
2           3  Cinder   5000.0
assignments =
   employee_id  project_id
0            1           1
1            2           1
2            3           1
3            4           2
4            5           2

Output

    title  budget_per_employee
0   Atlas                10000
1  Beacon                 4500

Premium problem

This one's part of Premium. Unlock the full Pandas track plus every other premium problem on the site.

Implement solve(...)