Department Headcount
depts has columns id and name (names are unique). emps has columns emp and dept_id. Return a dictionary mapping every department name to the number of employees in it (0 for empty departments).
Example 1
depts {"id":[1,2],"name":["hr","it"]}
emps {"emp":["a","b","c"],"dept_id":[2,2,2]}
returns {"hr":0,"it":3}
it has 3 people and hr has none.
Constraints
- The tables are small
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.
More pandas problems
- Earning More Than the ManagerMedium
- Employee BonusMedium
- Employee DepartmentsMedium
- Find Valid EmailsMedium
- First Time Below ZeroMedium
- Last Person on the BusMedium
- Manager NamesMedium
- Most Orders CustomerMedium