{ "cells": [ { "cell_type": "markdown", "id": "afbdce95", "metadata": {}, "source": [ "# U.S. Severe Weather Events 2000–2026\n", "\n", "Starter notebook for the Kaggle dataset in this folder. It loads `severe_weather_events.csv` with pandas and walks through quality checks and a first piece of analysis.\n", "\n", "**Files:** `severe_weather_events.csv`, `data_dictionary.csv`." ] }, { "cell_type": "markdown", "id": "0000f7f2", "metadata": {}, "source": [ "## 1. Load the data" ] }, { "cell_type": "code", "id": "891febfb", "metadata": {}, "execution_count": null, "outputs": [], "source": [ "import pandas as pd\n", "\n", "df = pd.read_csv(\"severe_weather_events.csv\", low_memory=False, parse_dates=[\"begin_datetime\", \"end_datetime\"])\n", "print(df.shape)" ] }, { "cell_type": "markdown", "id": "325de123", "metadata": {}, "source": [ "## 2. Shape, types and missing values" ] }, { "cell_type": "code", "id": "6eb42bc8", "metadata": {}, "execution_count": null, "outputs": [], "source": [ "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": "fac2e4ed", "metadata": {}, "source": [ "## 4. Events by type" ] }, { "cell_type": "code", "id": "7381262f", "metadata": {}, "execution_count": null, "outputs": [], "source": [ "df[\"event_type_group\"].value_counts().head(12).to_frame(\"events\")" ] }, { "cell_type": "markdown", "id": "e22c15c6", "metadata": {}, "source": [ "## 5. Fatalities by event family" ] }, { "cell_type": "code", "id": "56c16f26", "metadata": {}, "execution_count": null, "outputs": [], "source": [ "(df.groupby(\"event_type_group\")[\"total_deaths\"].sum()\n", " .sort_values(ascending=False).head(12).to_frame(\"deaths\"))" ] }, { "cell_type": "markdown", "id": "1c74efc4", "metadata": {}, "source": [ "## 6. Damage over time" ] }, { "cell_type": "code", "id": "8761155b", "metadata": {}, "execution_count": null, "outputs": [], "source": [ "yearly = df.groupby(\"year\")[\"damage_total_usd\"].sum() / 1e9\n", "yearly.plot(kind=\"bar\", figsize=(12, 4), title=\"Reported damage by year (US$ bn)\")" ] }, { "cell_type": "markdown", "id": "2351a46c", "metadata": {}, "source": [ "## 7. Tornado path lengths" ] }, { "cell_type": "code", "id": "e26d731b", "metadata": {}, "execution_count": null, "outputs": [], "source": [ "tor = df[(df[\"is_tornado\"] == \"true\") & df[\"path_length_km\"].notna()]\n", "tor[\"path_length_km\"].clip(upper=200).hist(bins=40, figsize=(8, 4))" ] }, { "cell_type": "markdown", "id": "afa626e0", "metadata": {}, "source": [ "## 8. Seasonality" ] }, { "cell_type": "code", "id": "b995c4b2", "metadata": {}, "execution_count": null, "outputs": [], "source": [ "df.pivot_table(index=\"month\", columns=\"event_type_group\", values=\"event_id\",\n", " aggfunc=\"count\").fillna(0).astype(int)" ] }, { "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 }