{ "cells": [ { "cell_type": "markdown", "id": "3658325e", "metadata": {}, "source": [ "# Formula 1 Race Results 1950–2026\n", "\n", "Starter notebook for the Kaggle dataset in this folder. It loads `f1_results.csv` with pandas and walks through quality checks and a first piece of analysis.\n", "\n", "**Files:** `f1_results.csv`, `data_dictionary.csv`." ] }, { "cell_type": "markdown", "id": "0000f7f2", "metadata": {}, "source": [ "## 1. Load the data" ] }, { "cell_type": "code", "id": "f3d1f8b5", "metadata": {}, "execution_count": null, "outputs": [], "source": [ "import pandas as pd\n", "\n", "df = pd.read_csv(\"f1_results.csv\", low_memory=False, parse_dates=[\"race_date\"])\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": "5daca7e2", "metadata": {}, "source": [ "## 4. Races per season" ] }, { "cell_type": "code", "id": "7f553bb4", "metadata": {}, "execution_count": null, "outputs": [], "source": [ "df.groupby(\"season\")[\"round\"].nunique().tail(30).plot(kind=\"bar\", figsize=(11, 4))" ] }, { "cell_type": "markdown", "id": "e6b6e770", "metadata": {}, "source": [ "## 5. Top drivers by wins" ] }, { "cell_type": "code", "id": "7f46f819", "metadata": {}, "execution_count": null, "outputs": [], "source": [ "df[df[\"is_win\"] == \"true\"][\"driver_id\"].value_counts().head(15).to_frame(\"wins\")" ] }, { "cell_type": "markdown", "id": "e0b6e325", "metadata": {}, "source": [ "## 6. Constructors" ] }, { "cell_type": "code", "id": "35ac5f8e", "metadata": {}, "execution_count": null, "outputs": [], "source": [ "df[\"constructor_name\"].value_counts().head(12).to_frame(\"results\")" ] }, { "cell_type": "markdown", "id": "9865f4ef", "metadata": {}, "source": [ "## 7. Grid vs finish" ] }, { "cell_type": "code", "id": "404a2120", "metadata": {}, "execution_count": null, "outputs": [], "source": [ "sub = df[(df[\"grid\"] > 0) & df[\"position\"].notna()]\n", "sub.plot.scatter(x=\"grid\", y=\"position\", s=4, alpha=0.15, figsize=(7, 7))" ] }, { "cell_type": "markdown", "id": "62cdd9e3", "metadata": {}, "source": [ "## 8. Status mix" ] }, { "cell_type": "code", "id": "c838a135", "metadata": {}, "execution_count": null, "outputs": [], "source": [ "df[\"status\"].value_counts().head(15).to_frame(\"results\")" ] }, { "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 }