FunctionRacerProblemsRace

Employee Departments

MediumpandasPython

employees has columns name and dept_id. depts has columns id and dept_name (ids are unique). Return a DataFrame with the columns name and dept_name, containing only employees whose dept_id exists in depts, in the order of employees.

Example 1

employees {"name":["Ann","Bo"],"dept_id":[2,9]}
depts {"id":[1,2],"dept_name":["hr","it"]}
returns {"columns":["name","dept_name"],"rows":[["Ann","it"]]}

Bo's department 9 is unknown, so Bo is dropped.

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