Aan de slagGa gratis aan de slag

Three table merge

To solidify the concept of a three DataFrame merge, practice another exercise. A reasonable extension of our review of Chicago business data would include looking at demographics information about the neighborhoods where the businesses are. A table with the median income by zip code has been provided to you. You will merge the licenses and wards tables with this new income-by-zip-code table called zip_demo.

The licenses, wards, and zip_demo DataFrames have been loaded for you.

Deze oefening maakt deel uit van de cursus

Joining Data with pandas

Cursus bekijken

Oefeninstructies

  • Starting with the licenses table, merge to it the zip_demo table on the zip column. Then merge the resulting table to the wards table on the ward column. Save result of the three merged tables to a variable named licenses_zip_ward.
  • Group the results of the three merged tables by the column alderman and find the median income.

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

# Merge licenses and zip_demo, on zip; and merge the wards on ward
licenses_zip_ward = licenses.merge____ \
            			____

# Print the results by alderman and show median income
print(____.groupby(____).agg({'income':'median'}))
Code bewerken en uitvoeren