Thursday, July 30, 2026

Data Analysis of the World Happiness Report: Insights

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
1Finland7.632
2Norway7.594
3Denmark7.555
4Iceland7.495
5Switzerland7.487
6Netherlands7.441
7Canada7.328
8New Zealand7.324
9Sweden7.314
10Australia7.272

Bottom 10 Least Happy Countries

Rank Country Score
147Haiti3.582
148Liberia3.495
149Syria3.462
150Rwanda3.408
151Yemen3.355
152Tanzania3.303
153South Sudan3.254
154Central African Rep.3.083
155Burundi2.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:

Meet the Authors
Zacharia Nyambu’s blog features multiple contributors with clear activity status.
Active ✔
πŸ§‘‍πŸ’»
Zacharia Nyambu
Lead Author
Inactive ✖
πŸ‘©‍πŸ’»
Linda Bahati
Co‑Author
Inactive ✖
πŸ‘¨‍πŸ’»
Jefferson Mwangolo
Co‑Author
Inactive ✖
πŸ‘©‍πŸŽ“
Florence Wavinya
Guest Author
Inactive ✖
πŸ‘©‍πŸŽ“
Esther Njeri
Guest Author
Inactive ✖
πŸ‘©‍πŸŽ“
Clemence Mwangolo
Guest Author

Followers