Employee Departments
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
- The result may have no rows
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.
More pandas problems
- Find Valid EmailsMedium
- First Time Below ZeroMedium
- Last Person on the BusMedium
- Manager NamesMedium
- Most Orders CustomerMedium
- Most Recent OrderMedium
- Person CitiesMedium
- Rearrange Products TableMedium