FunctionRacerProblemsRace

Department Headcount

MediumpandasPython

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

Race itor take your time

Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.

More pandas problems