{ "cells": [ { "cell_type": "markdown", "id": "5fd6a045", "metadata": {}, "source": [ "# Holocene Volcanoes\n", "\n", "Starter notebook for the Kaggle dataset in this folder. It loads `volcanoes.csv` with pandas and walks through quality checks and a first piece of analysis.\n", "\n", "**Files:** `volcanoes.csv`, `data_dictionary.csv`." ] }, { "cell_type": "markdown", "id": "0000f7f2", "metadata": {}, "source": [ "## 1. Load the data" ] }, { "cell_type": "code", "id": "5de088e4", "metadata": {}, "execution_count": null, "outputs": [], "source": [ "import pandas as pd\n", "\n", "df = pd.read_csv(\"volcanoes.csv\", low_memory=False)\n", "df[\"last_eruption_year\"] = pd.to_numeric(df[\"last_eruption_year\"], errors=\"coerce\")\n", "print(df.shape)" ] }, { "cell_type": "markdown", "id": "325de123", "metadata": {}, "source": [ "## 2. Shape, types and missing values" ] }, { "cell_type": "code", "id": "af6428f7", "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": "414fbbc2", "metadata": {}, "source": [ "## 4. The Ring of Fire\n", "\n", "Every volcano plotted by longitude and latitude." ] }, { "cell_type": "code", "id": "4962f3ef", "metadata": {}, "execution_count": null, "outputs": [], "source": [ "df.plot.scatter(x=\"longitude\", y=\"latitude\", s=6, alpha=0.6, figsize=(13, 6))" ] }, { "cell_type": "markdown", "id": "239b1742", "metadata": {}, "source": [ "## 5. Volcano types" ] }, { "cell_type": "code", "id": "3c77867b", "metadata": {}, "execution_count": null, "outputs": [], "source": [ "df[\"volcano_type_group\"].value_counts().head(10).plot.bar(figsize=(8, 4))" ] }, { "cell_type": "markdown", "id": "494d35f6", "metadata": {}, "source": [ "## 6. Eruption recency" ] }, { "cell_type": "code", "id": "e078c04a", "metadata": {}, "execution_count": null, "outputs": [], "source": [ "df[\"eruption_recency_class\"].value_counts().plot.pie(figsize=(6, 6), autopct=\"%1.1f%%\")" ] }, { "cell_type": "markdown", "id": "f39e77da", "metadata": {}, "source": [ "## 7. Elevation distribution by latitude band" ] }, { "cell_type": "code", "id": "59c2b790", "metadata": {}, "execution_count": null, "outputs": [], "source": [ "df.boxplot(column=\"elevation_m\", by=\"latitude_band\", figsize=(12, 5), rot=30)" ] }, { "cell_type": "markdown", "id": "4e098e80", "metadata": {}, "source": [ "## 8. Most active countries since 1500" ] }, { "cell_type": "code", "id": "a448a8dc", "metadata": {}, "execution_count": null, "outputs": [], "source": [ "(df[df[\"is_historical_eruption\"].astype(str).str.lower() == \"true\"]\n", " .groupby(\"country\").size().sort_values(ascending=False).head(15).plot.barh(figsize=(8, 6)))" ] }, { "cell_type": "markdown", "id": "ce46e32e", "metadata": {}, "source": [ "## 9. Tectonic settings" ] }, { "cell_type": "code", "id": "7ed04588", "metadata": {}, "execution_count": null, "outputs": [], "source": [ "df[\"tectonic_setting\"].value_counts().head(10)" ] }, { "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 }