1. Read, clean, and prepare data to build maps
1.1. Create your first choropleth world map
1.2. Create dictionaries: JSON and GeoJSON
1.3. Read and clean immigration data
2. Problem & Solution
2.1. Fusion of GeoJson and immigration data
2.2. Create your first map with pinpoints
2.3. Using WITS data to build a bar graph
2.4. Insert a bar graph in a pinpoint map
2.5. Obtaining the risk of each country
Load the notebook with commands developed in step 2.4. (click on the link):
https://colab.research.google.com/drive/1ZxQNqyr3KssnHHIXhmxu1Q_UU7PyVQtL?usp=sharing
The Numbeo site gives partial information about the risks of a country. In particular, the site provides this information within the format of a map: https://www.numbeo.com/crime/rankings_by_country.jsp
The next code helps to extract data about the risk of each country, including the metrics from Numbeo site.
import pandas as pd
#https://docs.google.com/spreadsheets/d/1Z0ynhW1qJRLHmRbCHqBDGGXm_4tc-YdZ/edit?usp=sharing&ouid=106640872116257813737&rtpof=true&sd=true
url = 'https://drive.google.com/uc?export=download&id=1Z0ynhW1qJRLHmRbCHqBDGGXm_4tc-YdZ'
xls = pd.ExcelFile(url)
xls
<pandas.io.excel._base.ExcelFile at 0x7ba5ca19f8b0>
The next code helps to show the name of all available sheets.
sheet_names = xls.sheet_names
sheet_names
['Data source_country', 'Country Crime Risk Score', 'Country Tax Risk Score', 'Country Risk Score', 'Number of countries for RiskCat']
The next code extracts the information from the fourth sheet and stores it in the variable df_risk .
df_risk = pd.read_excel(xls, sheet_names[3])
df_risk
The next code obtains the names of the columns from the variable df_risk .
df_risk.columns
Index(['Countryname', 'Country Crime Risk Score', 'Country Tax Risk Score', '(Country Crime Risk Score+Country Tax Risk Score)/2=Country Risk Score'], dtype='object')
The next code renames the names of the columns from the variable df_risk .
df_risk.reset_index(inplace=True)
df_risk.rename(columns={'Countryname': 'country', 'Country Crime Risk Score': 'Crime_Score', 'Country Tax Risk Score': 'Tax_Score', '(Country Crime Risk Score+Country Tax Risk Score)/2=Country Risk Score': 'Combined_Score'},inplace=True)
df_risk
The Python code with all the steps is summarized in this Google Colab (click on the link):
https://colab.research.google.com/drive/1xHbcvflGxg-T2cCXkhvGE2Ubyr9t5_hE?usp=sharing