Choropleth maps are one of the most interesting and useful visualizations. They are important because they can provide information for geographic location, they look beautiful and grab attention in a presentation. Several different libraries can be used to do that. In this tutorial, I will use folium.

What is a choropleth map?

Here is the definition from Wikipedia:

Choropleth maps provide an easy way to visualize how a measurement varies across a geographic area or show the level of variability within a region. A heat map or isarithmic map is similar but does not use a priori geographic areas. They are the most common type of thematic map because published statistical data (from government or other sources) is generally aggregated into well-known geographic units, such as countries, states, provinces, and counties, and thus they are relatively easy to create using GISspreadsheets, or other software tools.

In simple and easy words, choropleth maps are the maps that show the information by geolocation using color on the map. See some of the pictures below to get more understanding.

Data Preparation

Data preparation is an important and common task for all data scientists. The dataset I used here is reasonably nice and clean. But for this visualization, I still need to work on it a bit. Let’s import the necessary libraries and the dataset.

import pandas as pd
import numpy as np

df = pd.read_excel('https://s3-api.us-geo.objectstorage.softlayer.net/cf-courses-data/CognitiveClass/DV0101EN/labs/Data_Files/Canada.xlsx',
                     sheet_name='Canada by Citizenship',
                     skiprows=range(20),
                     skipfooter=2)

I cannot show a screenshot of the dataset here because it’s too big. I encourage you to run the code by yourself. That’s the only way to learn.

#data-visualization #data-analytics #python #data-science #data science

A Step by Step Guide to Interactive Choropleth Map in Python
15.25 GEEK