{ "cells": [ { "cell_type": "markdown", "id": "fa66a7f4", "metadata": {}, "source": [ "# FDA Drug Recalls — Enforcement Reports\n", "\n", "Starter notebook for the Kaggle dataset in this folder. It loads `fda_drug_recalls.csv` with pandas and walks through quality checks and a first piece of analysis.\n", "\n", "**Files:** `fda_drug_recalls.csv`, `data_dictionary.csv`." ] }, { "cell_type": "markdown", "id": "0000f7f2", "metadata": {}, "source": [ "## 1. Load the data" ] }, { "cell_type": "code", "id": "9c39f668", "metadata": {}, "execution_count": null, "outputs": [], "source": [ "import pandas as pd\n", "\n", "df = pd.read_csv(\"fda_drug_recalls.csv\", low_memory=False)\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": "a61c8801", "metadata": {}, "source": [ "## 4. Classification mix" ] }, { "cell_type": "code", "id": "0d49ced4", "metadata": {}, "execution_count": null, "outputs": [], "source": [ "df[\"classification\"].value_counts().to_frame(\"recalls\")" ] }, { "cell_type": "markdown", "id": "acd19322", "metadata": {}, "source": [ "## 5. Recalls by year" ] }, { "cell_type": "code", "id": "a6779f01", "metadata": {}, "execution_count": null, "outputs": [], "source": [ "df[\"year\"].value_counts().sort_index().plot(kind=\"bar\", figsize=(11, 4))" ] }, { "cell_type": "markdown", "id": "063581d8", "metadata": {}, "source": [ "## 6. Reason categories" ] }, { "cell_type": "code", "id": "131902a5", "metadata": {}, "execution_count": null, "outputs": [], "source": [ "df[\"reason_category\"].value_counts().to_frame(\"recalls\")" ] }, { "cell_type": "markdown", "id": "07dc383b", "metadata": {}, "source": [ "## 7. Processing lag" ] }, { "cell_type": "code", "id": "3bfd98e5", "metadata": {}, "execution_count": null, "outputs": [], "source": [ "df[\"days_initiation_to_classification\"].dropna().clip(0, 1000).hist(bins=40, figsize=(8, 4))" ] }, { "cell_type": "markdown", "id": "584e3266", "metadata": {}, "source": [ "## 8. Top firms" ] }, { "cell_type": "code", "id": "322d5fae", "metadata": {}, "execution_count": null, "outputs": [], "source": [ "df[\"recalling_firm\"].value_counts().head(15).to_frame(\"recalls\")" ] }, { "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 }