Building a polished Geopandas choropleth
After merging the counts_df
with permits_by_district
, you will create a column with normalized permit_density
by dividing the count of permits in each council district by the area of that council district. Then you will plot your final geopandas
choropleth of the building projects in each council district.
Este ejercicio forma parte del curso
Visualizing Geospatial Data in Python
Instrucciones del ejercicio
- Merge
permits_by_district
andcounts_df
ondistrict
to createdistricts_and_permits
. - Using
apply()
and a lambda expression, calculate a new column indistricts_and_permits
calledpermit_density
. Divide counts by areas. - Plot a choropleth of the
districts_and_permits
, usingpermit_density
with theOrRd
colormap, and black outlines. - Add axis labels (longitude and latitude) and the title provided. Show your plot.
Ejercicio interactivo práctico
Prueba este ejercicio y completa el código de muestra.
# Merge permits_by_district and counts_df
districts_and_permits = pd.merge(____, ____, on = ____)
# Create permit_density column
districts_and_permits['permit_density'] = districts_and_permits.apply(lambda row: row.____ / row.____, axis = 1)
print(districts_and_permits.head(2))
# Create choropleth plot
districts_and_permits.plot(column = ____, ____ = 'OrRd', ____ = 'black', legend = True)
# Add axis labels and title
plt.xlabel(____)
plt.ylabel(____)
plt.title('2017 Building Project Density by Council District')
plt.show()