{ "cells": [ { "cell_type": "markdown", "id": "7abc89a4", "metadata": {}, "source": [ "# Nobel Prize Laureates\n", "\n", "Starter notebook for the Kaggle dataset in this folder. It loads `nobel_laureates.csv` with pandas and walks through quality checks and a first piece of analysis.\n", "\n", "**Files:** `nobel_laureates.csv`, `data_dictionary.csv`." ] }, { "cell_type": "markdown", "id": "0000f7f2", "metadata": {}, "source": [ "## 1. Load the data" ] }, { "cell_type": "code", "id": "467066f6", "metadata": {}, "execution_count": null, "outputs": [], "source": [ "import pandas as pd\n", "\n", "df = pd.read_csv(\"nobel_laureates.csv\")\n", "df[\"age_at_award\"] = pd.to_numeric(df[\"age_at_award\"], errors=\"coerce\")\n", "print(df.shape)\n", "df[[\"prize_year\", \"category\", \"known_name\", \"age_at_award\"]].head()" ] }, { "cell_type": "markdown", "id": "325de123", "metadata": {}, "source": [ "## 2. Shape, types and missing values" ] }, { "cell_type": "code", "id": "4de324f4", "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": "2fe8dde8", "metadata": {}, "source": [ "## 4. Prizes per decade" ] }, { "cell_type": "code", "id": "3f25d3c0", "metadata": {}, "execution_count": null, "outputs": [], "source": [ "(df.drop_duplicates([\"prize_year\", \"category\"])\n", " .groupby([df[\"decade\"], \"category\"]).size().unstack(fill_value=0)\n", " .plot.bar(stacked=True, figsize=(12, 6)))" ] }, { "cell_type": "markdown", "id": "54e8e1e2", "metadata": {}, "source": [ "## 5. Age at award by category" ] }, { "cell_type": "code", "id": "72117551", "metadata": {}, "execution_count": null, "outputs": [], "source": [ "df.boxplot(column=\"age_at_award\", by=\"category\", figsize=(11, 5), rot=30)" ] }, { "cell_type": "markdown", "id": "e9308f66", "metadata": {}, "source": [ "## 6. Gender over time" ] }, { "cell_type": "code", "id": "435bcb0f", "metadata": {}, "execution_count": null, "outputs": [], "source": [ "(df[df[\"laureate_type\"] == \"person\"]\n", " .assign(gender=lambda t: t[\"gender\"].fillna(\"unknown\"))\n", " .groupby([\"decade\", \"gender\"]).size().unstack(fill_value=0)\n", " .plot.bar(stacked=True, figsize=(12, 5)))" ] }, { "cell_type": "markdown", "id": "aaacac45", "metadata": {}, "source": [ "## 7. Most frequent affiliations" ] }, { "cell_type": "code", "id": "d0388848", "metadata": {}, "execution_count": null, "outputs": [], "source": [ "df[\"first_affiliation\"].value_counts().head(20).sort_values().plot.barh(figsize=(8, 6))" ] }, { "cell_type": "markdown", "id": "b0b76b2f", "metadata": {}, "source": [ "## 8. Real prize value per laureate" ] }, { "cell_type": "code", "id": "05faea65", "metadata": {}, "execution_count": null, "outputs": [], "source": [ "val = (df.drop_duplicates([\"prize_year\", \"category\"])\n", " .assign(per_laureate=lambda t: t[\"prize_amount_adjusted_sek\"] / t[\"n_laureates\"]))\n", "val.sort_values(\"prize_year\").plot(x=\"prize_year\", y=\"per_laureate\", figsize=(10, 5))" ] }, { "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 }