{ "cells": [ { "cell_type": "markdown", "id": "9e730432", "metadata": {}, "source": [ "# Rust Crate Ecosystem\n", "\n", "Starter notebook for the Kaggle dataset in this folder. It loads `rust_crates.csv` with pandas and walks through quality checks and a first piece of analysis.\n", "\n", "**Files:** `rust_crates.csv`, `data_dictionary.csv`." ] }, { "cell_type": "markdown", "id": "0000f7f2", "metadata": {}, "source": [ "## 1. Load the data" ] }, { "cell_type": "code", "id": "c1f75256", "metadata": {}, "execution_count": null, "outputs": [], "source": [ "import pandas as pd\n", "\n", "df = pd.read_csv(\"rust_crates.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": "d2560060", "metadata": {}, "source": [ "## 4. Download distribution" ] }, { "cell_type": "code", "id": "8cbbcd20", "metadata": {}, "execution_count": null, "outputs": [], "source": [ "df[\"downloads\"].dropna().clip(upper=10_000_000).hist(bins=50, figsize=(9, 4), log=True)" ] }, { "cell_type": "markdown", "id": "55975174", "metadata": {}, "source": [ "## 5. Release cadence" ] }, { "cell_type": "code", "id": "975d6542", "metadata": {}, "execution_count": null, "outputs": [], "source": [ "df[\"versions_per_year\"].dropna().clip(upper=50).hist(bins=40, figsize=(8, 4))" ] }, { "cell_type": "markdown", "id": "ceb1d934", "metadata": {}, "source": [ "## 6. Maintenance" ] }, { "cell_type": "code", "id": "dcba5659", "metadata": {}, "execution_count": null, "outputs": [], "source": [ "df[\"days_since_update\"].dropna().clip(upper=2000).hist(bins=50, figsize=(8, 4))" ] }, { "cell_type": "markdown", "id": "3858f33b", "metadata": {}, "source": [ "## 7. Domain flags" ] }, { "cell_type": "code", "id": "1dade8d6", "metadata": {}, "execution_count": null, "outputs": [], "source": [ "for c in [\"is_async\", \"is_cli\", \"is_wasm\", \"is_embedded\", \"is_proc_macro\", \"is_serialization\"]:\n", " print(c, int((df[c].astype(str).str.lower() == \"true\").sum()))" ] }, { "cell_type": "markdown", "id": "ce9b2128", "metadata": {}, "source": [ "## 8. Downloads per day vs age" ] }, { "cell_type": "code", "id": "a56c4005", "metadata": {}, "execution_count": null, "outputs": [], "source": [ "sub = df.dropna(subset=[\"age_days\", \"downloads_per_day\"])\n", "sub.plot.scatter(x=\"age_days\", y=\"downloads_per_day\", s=3, alpha=0.2, logy=True, figsize=(8, 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 }