Get startedGet started for free

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.

This exercise is part of the course

Analyzing US Census Data in Python

View Course

Exercise instructions

  • 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"

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# 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()
Edit and Run Code