ComeçarComece de graça

Choropleth Map of Internet Access

In this exercise you will load a geospatial data file and create a simple choropleth map. The data come from ACS Table B28011 - "Internet Subscriptions in Household", and include columns representing total households, those with internet and no_internet access, and various kinds of internet connectivity.

Remember that choropleth maps should show rates or proportions, not counts. After loading the data, you will calculate the percentage of households with no internet access, using columns no_internet and total households.

Este exercício faz parte do curso

Analyzing US Census Data in Python

Ver curso

Instruções do exercício

  • Import geopandas using the alias gpd
  • Use the read_file method of geopandas to load the file "states_internet.gpkg"
  • Calculate the percentage of households with no internet access as 100 times the number of households with no_internet, divided by the total
  • Create a choropleth map of this percentage by setting the column parameter to the name of the new column; set the colormap (cmap parameter) to "YlGnBu"

Exercício interativo prático

Experimente este exercício completando este código de exemplo.

# Import geopandas
____

# Load geospatial data
geo_state = ____

# View GeoDataFrame columns
print(geo_state.columns)

# Calculate percent of households with no internet
geo_state["pct_no_internet"] = ____

# Create choropleth map using YlGnBu colormap
geo_state.plot(____)
plt.show()
Editar e executar o código