Social Progress Index Analysis using Python

The Social Progress Index (SPI) is a measure that gives an understanding of social progress globally. It helps in understanding how much countries care about the overall development of the citizens. If you want to know how to analyze the social progress index, this article is for you. This article will take you through Social Progress Index analysis using Python.

Social Progress Index Analysis

The Social Progress Index score is calculated by analyzing the overall development of the citizens of a country. Below are all the factors considered for calculating the Social Progress Score:

  1. Basic human needs
  2. Wellbeing
  3. Opportunities
  4. Nutritional and basic medical care
  5. Water and sanitation
  6. Shelter
  7. Personal Safety
  8. Access to basic knowledge
  9. Access to information and communication
  10. Health and wellness
  11. Environment quality
  12. Personal rights
  13. Personal freedom and choice
  14. Inclusiveness
  15. Access to advanced education

So these are the primary factors considered while calculating the SPI score of a country. I found a dataset on Kaggle that contains all these factors. It will be helpful to analyze the Social Progress Index. You can download the dataset from here.

Before moving forward, I want to let you know that if you want to create an advanced Data Science project on Social Progress Index Analysis, I recommend you use Tableau as such datasets are better visualized and analyzed on dashboards. For example, have a look at the dashboard made by socialprogress.org.

The section below will take you through Social Progress Index Analysis using Python.

Social Progress Index Analysis using Python

Let’s start this task by importing the necessary Python libraries and the dataset:

import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
import plotly.express as px
import plotly.graph_objs as go
from plotly.offline import iplot

data = pd.read_csv("spi.csv")
print(data.head())
   spi_rank      country  spi_score  basic_human_needs  wellbeing  \
0       1.0       Norway      92.63              95.29      93.30   
1       2.0      Finland      92.26              95.62      93.09   
2       3.0      Denmark      92.15              95.30      92.74   
3       4.0      Iceland      91.78              96.66      93.65   
4       5.0  Switzerland      91.78              95.25      93.80   

   opportunity  basic_nutri_med_care  water_sanitation  shelter  \
0        89.30                 98.81             98.33    93.75   
1        88.07                 98.99             99.26    96.48   
2        88.41                 98.62             98.21    94.92   
3        85.04                 98.99             98.82    93.16   
4        86.28                 98.72             98.96    92.97   

   personal_safety  access_basic_knowledge  access_info_comm  health_wellness  \
0            90.29                   98.66             95.80            89.32   
1            87.75                   96.32             95.14            85.73   
2            89.46                   97.44             98.18            85.15   
3            95.66                   99.51             93.12            91.02   
4            90.35                   98.60             95.07            91.50   

   env_quality  personal_rights  personal_freedom_choice  inclusiveness  \
0        89.44            96.34                    91.16          83.77   
1        95.15            96.13                    88.10          82.81   
2        90.20            97.08                    90.03          81.64   
3        90.93            95.14                    88.01          77.63   
4        90.05            96.69                    90.65          74.81   

   access_adv_edu  
0           85.92  
1           85.23  
2           84.89  
3           79.39  
4           82.99  

According to the SPI rank, Norway tops the Social Process Index globally. Let’s have a look at the column insights before moving forward:

print(data.info())
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 169 entries, 0 to 168
Data columns (total 18 columns):
 #   Column                   Non-Null Count  Dtype  
---  ------                   --------------  -----  
 0   spi_rank                 168 non-null    float64
 1   country                  169 non-null    object 
 2   spi_score                169 non-null    float64
 3   basic_human_needs        169 non-null    float64
 4   wellbeing                169 non-null    float64
 5   opportunity              169 non-null    float64
 6   basic_nutri_med_care     169 non-null    float64
 7   water_sanitation         169 non-null    float64
 8   shelter                  169 non-null    float64
 9   personal_safety          169 non-null    float64
 10  access_basic_knowledge   169 non-null    float64
 11  access_info_comm         169 non-null    float64
 12  health_wellness          169 non-null    float64
 13  env_quality              169 non-null    float64
 14  personal_rights          169 non-null    float64
 15  personal_freedom_choice  169 non-null    float64
 16  inclusiveness            169 non-null    float64
 17  access_adv_edu           169 non-null    float64
dtypes: float64(17), object(1)
memory usage: 23.9+ KB
None

Now let’s have a look at the average, highest, and minimum of the SPI score so that we can categorize scores as High and low:

print("Highet SPI Score : ", data["spi_score"].max())
print("Lowest SPI Score : ", data["spi_score"].min())
print("Average SPI Score: ", data["spi_score"].mean())
Highet SPI Score :  92.63
Lowest SPI Score :  32.5
Average SPI Score:  67.43313609467457

As 67 is the average SPI score and 92 is the highest, we can consider 85 as the qualifying score for a high SPI score. So let’s analyze some data about the countries with high SPI scores.

Let’s start with a look at the countries with better basic human needs facilities:

fig = px.scatter(data.query("spi_score >= 85"), 
                 x="basic_human_needs", 
                 y="spi_score",
                 size="spi_score", 
                 color="country",
                 hover_name="country",
                 title= "Countries with Better Basic Human Needs", 
                 log_x=True, size_max=60)
fig.show()
Countries with Better Basic Human Needs

Iceland and Japan are the top 2 countries with better basic human needs facilities. Now let’s have a look at the countries with better opportunities:

fig = px.scatter(data.query("spi_score >= 85"), 
                 x="opportunity", 
                 y="spi_score",
                 size="spi_score", 
                 color="country",
                 hover_name="country",
                 title= "Countries with Better Opportunities", 
                 log_x=True, size_max=60)
fig.show()
Social Progress Index Analysis: Countries with Better Opportunities

Norway, Denmark, and Finland are the top 3 countries with better opportunities. Now let’s have a look at the countries with better nutrition and medical care facilities:

fig = px.scatter(data.query("spi_score >= 85"), 
                 x="basic_nutri_med_care", 
                 y="spi_score",
                 size="spi_score", 
                 color="country",
                 hover_name="country", 
                 title = "Countries with Better Basic Nutrition & Medical Care",
                 log_x=True, size_max=60)
fig.show()
Countries with Better Basic Nutrition & Medical Care

Finland, Iceland, and Norway are the top 3 countries with better nutrition and medical care facilities. Now let’s have a look at the countries with better water sanitation:

fig = px.scatter(data.query("spi_score >= 85"), 
                 x="water_sanitation", 
                 y="spi_score",
                 size="spi_score", 
                 color="country",
                 hover_name="country", 
                 title = "Countries with Better Water Sanitation",
                 log_x=True, size_max=60)
fig.show()
Countries with Better Water Sanitation

Finland and Switzerland are the top 2 countries with better water sanitation.

So, this is how we can analyze all the factors considered to calculate the SPI score. Now let’s create a visualization to analyze the overall Social Progress Index scores globally using a choropleth map:

values = dict(type = 'choropleth', 
           locations = data['country'],
           locationmode = 'country names',
           colorscale='Blues',
           z = data['spi_score'], 
           text = data['country'],
           colorbar = {'title':'Social Progress Index'})

layout = dict(title = 'Social Progress Index', 
              geo = dict(showframe = True, 
                         projection = {'type': 'azimuthal equal area'}))

figure = go.Figure(data = [values], layout=layout)
iplot(figure)
Social Progress Index Analysis

So this is how you can analyze the Social Progress Index using the Python programming language.

Summary

The Social Progress Index (SPI) is a measure that gives an understanding of social progress globally. It helps in understanding how much countries care about the overall development of the citizens. I hope you liked this article on Social Progress Index Analysis using Python. Feel free to ask valuable questions in the comments section below.

Aman Kharwal
Aman Kharwal

I'm a writer and data scientist on a mission to educate others about the incredible power of data📈.

Articles: 1431

Leave a Reply