{ "cells": [ { "cell_type": "markdown", "id": "a9490bee", "metadata": {}, "source": [ "# Global Health Panel\n", "\n", "Starter notebook for the Kaggle dataset in this folder. It loads `who_health_panel.csv` with pandas and walks through quality checks and a first piece of analysis.\n", "\n", "**Files:** `who_health_panel.csv`, `data_dictionary.csv`." ] }, { "cell_type": "markdown", "id": "0000f7f2", "metadata": {}, "source": [ "## 1. Load the data" ] }, { "cell_type": "code", "id": "734c0d0d", "metadata": {}, "execution_count": null, "outputs": [], "source": [ "import pandas as pd\n", "\n", "df = pd.read_csv(\"who_health_panel.csv\", low_memory=False)\n", "df[\"life_expectancy\"] = pd.to_numeric(df[\"life_expectancy\"], errors=\"coerce\")\n", "print(df.shape)" ] }, { "cell_type": "markdown", "id": "325de123", "metadata": {}, "source": [ "## 2. Shape, types and missing values" ] }, { "cell_type": "code", "id": "466b62c3", "metadata": {}, "execution_count": null, "outputs": [], "source": [ "import pandas as pd\n", "\n", "print(f\"{df.shape[0]:,} rows x {df.shape[1]} columns\")\n", "\n", "missing = df.isna().mean().mul(100).sort_values(ascending=False)\n", "missing[missing > 0].round(1).to_frame(\"missing_%\").head(15)" ] }, { "cell_type": "markdown", "id": "f2d963fe", "metadata": {}, "source": [ "## 3. Numeric summary" ] }, { "cell_type": "code", "id": "aa2f8fd4", "metadata": {}, "execution_count": null, "outputs": [], "source": [ "df.describe(include='number').T.round(2).head(20)" ] }, { "cell_type": "markdown", "id": "9bf05f08", "metadata": {}, "source": [ "## 4. Coverage of the panel" ] }, { "cell_type": "code", "id": "91cdecbe", "metadata": {}, "execution_count": null, "outputs": [], "source": [ "df.groupby(\"year\")[\"n_indicators_reported\"].mean().round(1).plot(figsize=(9, 4))" ] }, { "cell_type": "markdown", "id": "d5f7f36a", "metadata": {}, "source": [ "## 5. Life expectancy by region over time" ] }, { "cell_type": "code", "id": "8430f315", "metadata": {}, "execution_count": null, "outputs": [], "source": [ "(df.dropna(subset=[\"life_expectancy\"])\n", " .groupby([\"year\", \"region\"])[\"life_expectancy\"].mean().unstack()\n", " .plot(figsize=(11, 5)))" ] }, { "cell_type": "markdown", "id": "600df6ea", "metadata": {}, "source": [ "## 6. Life expectancy vs health spending" ] }, { "cell_type": "code", "id": "e03f69db", "metadata": {}, "execution_count": null, "outputs": [], "source": [ "sub = df.dropna(subset=[\"health_spend_per_capita_usd\", \"life_expectancy\"]).query(\"year >= 2015\")\n", "sub.plot.scatter(x=\"health_spend_per_capita_usd\", y=\"life_expectancy\", logx=True, s=8, figsize=(9, 5))" ] }, { "cell_type": "markdown", "id": "299dff30", "metadata": {}, "source": [ "## 7. Workforce density and child mortality" ] }, { "cell_type": "code", "id": "bf3699ba", "metadata": {}, "execution_count": null, "outputs": [], "source": [ "sub = df.dropna(subset=[\"doctors_per_1000\", \"under5_mortality_per_1000\"]).query(\"year >= 2015\")\n", "sub.plot.scatter(x=\"doctors_per_1000\", y=\"under5_mortality_per_1000\", logy=True, s=8, figsize=(9, 5))" ] }, { "cell_type": "markdown", "id": "494c0566", "metadata": {}, "source": [ "## 8. Country profile snapshot" ] }, { "cell_type": "code", "id": "d31007c7", "metadata": {}, "execution_count": null, "outputs": [], "source": [ "latest = df[df[\"year\"] == df[\"year\"].max()]\n", "latest.nlargest(10, \"life_expectancy\")[[\"country_name\", \"life_expectancy\", \"healthy_life_expectancy\",\n", " \"health_spend_pct_gdp\", \"doctors_per_1000\"]]" ] }, { "cell_type": "markdown", "id": "06cc1cd0", "metadata": {}, "source": [ "## 9. Missingness by indicator" ] }, { "cell_type": "code", "id": "f6d3d76c", "metadata": {}, "execution_count": null, "outputs": [], "source": [ "cols = [c for c in df.columns if df[c].dtype != object]\n", "df[cols].isna().mean().mul(100).sort_values(ascending=False).round(1).head(20)" ] }, { "cell_type": "markdown", "id": "6e43770c", "metadata": {}, "source": [ "## Next steps\n", "\n", "See `KAGGLE.md` for analysis ideas, caveats and provenance." ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "name": "python", "version": "3.11", "mimetype": "text/x-python", "file_extension": ".py", "codemirror_mode": { "name": "ipython", "version": 3 }, "pygments_lexer": "ipython3", "nbconvert_exporter": "python" } }, "nbformat": 4, "nbformat_minor": 5 }