Person Cities
people has columns id and name. addresses has columns person_id and city, with at most one address per person. Return a DataFrame with the columns name and city for every person, in the order of people. Use the text "Unknown" as the city of people with no address.
Example 1
people {"id":[1,2],"name":["Ana","Ben"]}
addresses {"person_id":[2],"city":["Oslo"]}
returns {"columns":["name","city"],"rows":[["Ana","Unknown"],["Ben","Oslo"]]}
Ana has no address.
Constraints
- Every person appears once in the answer
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.
More pandas problems
- Rearrange Products TableMedium
- Record ReadingsMedium
- Reformat Department TableMedium
- Revenue per ProductMedium
- Rising TemperatureMedium
- Salespeople Without Red OrdersMedium
- Three in a RowMedium
- Top Earners per DepartmentMedium