Data Analysis of the World Happiness Report: Insights & Findings
What makes a nation happy? In this post, we analyze the World Happiness Report dataset using Python, pandas, and Seaborn. We'll explore dataset structures, handle missing values, inspect factor correlations, compare the happiest vs. least happy countries, and perform a deep-dive benchmark into Kenya's happiness metrics.
1. Data Loading & Preprocessing
The dataset contains 156 entries covering key socio-economic factors such as GDP per capita, social support, healthy life expectancy, freedom, generosity, and corruption perceptions.
import pandas as pd
import numpy as np
# Load the dataset
df = pd.read_csv('2018.csv')
# Impute missing 'Perceptions of corruption' value with median
if df['Perceptions of corruption'].isnull().any():
median_corruption = df['Perceptions of corruption'].median()
df['Perceptions of corruption'].fillna(median_corruption, inplace=True)
print(f"Missing value imputed with median: {median_corruption:.3f}")
Statistical Summary of the Dataset
| Metric | Happiness Score | GDP per Capita | Social Support | Healthy Life Exp. | Freedom |
|---|---|---|---|---|---|
| Mean | 5.376 | 0.891 | 1.213 | 0.597 | 0.455 |
| Std Dev | 1.120 | 0.392 | 0.302 | 0.248 | 0.162 |
| Min | 2.905 | 0.000 | 0.000 | 0.000 | 0.000 |
| Max | 7.632 | 2.096 | 1.644 | 1.008 | 0.724 |
2. Key Correlation Drivers of Happiness
By analyzing the correlation matrix of the variables, we observe strong positive relationships between a nation's overall score and specific development metrics:
- GDP per Capita ($r = 0.80$): Strongest driver of overall happiness scores.
- Healthy Life Expectancy ($r = 0.78$): Highly correlated with national well-being.
- Social Support ($r = 0.75$): Crucial safety-net metric influencing overall satisfaction.
- Freedom to Make Life Choices ($r = 0.54$): Moderate positive impact.
- Generosity ($r = 0.14$): Weak correlation with national happiness rankings.
3. The Top 10 vs. Bottom 10 Countries
Top 10 Happiest Countries
| Rank | Country | Score |
|---|---|---|
| 1 | Finland | 7.632 |
| 2 | Norway | 7.594 |
| 3 | Denmark | 7.555 |
| 4 | Iceland | 7.495 |
| 5 | Switzerland | 7.487 |
| 6 | Netherlands | 7.441 |
| 7 | Canada | 7.328 |
| 8 | New Zealand | 7.324 |
| 9 | Sweden | 7.314 |
| 10 | Australia | 7.272 |
Bottom 10 Least Happy Countries
| Rank | Country | Score |
|---|---|---|
| 147 | Haiti | 3.582 |
| 148 | Liberia | 3.495 |
| 149 | Syria | 3.462 |
| 150 | Rwanda | 3.408 |
| 151 | Yemen | 3.355 |
| 152 | Tanzania | 3.303 |
| 153 | South Sudan | 3.254 |
| 154 | Central African Rep. | 3.083 |
| 155 | Burundi | 2.905 |
4. Case Benchmark: Kenya vs. Top 10 vs. Bottom 10
Evaluating Kenya (Rank 124, Score: 4.410) against global averages shows significant strengths in Social Support (1.048) and Generosity (0.352), while economic output (GDP per capita) and corruption perceptions remain primary areas for development.
import matplotlib.pyplot as plt
import seaborn as sns
# Comparing Kenya against Top 10 and Bottom 10 averages
factors = ['GDP per capita', 'Social support', 'Healthy life expectancy',
'Freedom to make life choices', 'Generosity', 'Perceptions of corruption']
# Visualization code setup
plt.figure(figsize=(12, 6))
sns.barplot(x='Factor', y='Value', hue='Group', data=comparison_df_melted, palette='coolwarm')
plt.title('Comparison of Happiness Factors: Kenya vs. Avg Top 10 vs. Avg Bottom 10')
plt.xticks(rotation=45)
plt.show()
Key Takeaway: Higher levels of social support and individual freedom serve as major buffers for lower-income countries, but baseline economic performance (GDP) and health infrastructure remain essential for entering the top tiers of global happiness.

No comments:
Post a Comment