{ "cells": [ { "cell_type": "markdown", "id": "2597d255", "metadata": {}, "source": [ "# SEC-Registered Companies\n", "\n", "Starter notebook for the Kaggle dataset in this folder. It loads `sec_companies.csv` with pandas and walks through quality checks and a first piece of analysis.\n", "\n", "**Files:** `sec_companies.csv`, `data_dictionary.csv`." ] }, { "cell_type": "markdown", "id": "0000f7f2", "metadata": {}, "source": [ "## 1. Load the data" ] }, { "cell_type": "code", "id": "3a48cb89", "metadata": {}, "execution_count": null, "outputs": [], "source": [ "import pandas as pd\n", "\n", "df = pd.read_csv(\"sec_companies.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": "cca2a650", "metadata": {}, "source": [ "## 4. Entity types" ] }, { "cell_type": "code", "id": "34d8a20d", "metadata": {}, "execution_count": null, "outputs": [], "source": [ "df[\"entity_type\"].value_counts().head(10).to_frame(\"companies\")" ] }, { "cell_type": "markdown", "id": "e1ef1e04", "metadata": {}, "source": [ "## 5. Industry divisions" ] }, { "cell_type": "code", "id": "c2f5af66", "metadata": {}, "execution_count": null, "outputs": [], "source": [ "df[\"sic_division\"].value_counts().to_frame(\"companies\")" ] }, { "cell_type": "markdown", "id": "211f83c4", "metadata": {}, "source": [ "## 6. Filing activity" ] }, { "cell_type": "code", "id": "382b9baa", "metadata": {}, "execution_count": null, "outputs": [], "source": [ "df[\"days_since_latest_filing\"].dropna().clip(upper=3000).plot(\n", " kind=\"hist\", bins=50, figsize=(10, 4), title=\"Days since latest filing\")" ] }, { "cell_type": "markdown", "id": "b67aac40", "metadata": {}, "source": [ "## 7. Filing mix by division" ] }, { "cell_type": "code", "id": "e0503db8", "metadata": {}, "execution_count": null, "outputs": [], "source": [ "df.groupby(\"sic_division\")[[\"filings_10k\", \"filings_8k\", \"filings_form4\"]].mean().round(1)" ] }, { "cell_type": "markdown", "id": "0f9bcda0", "metadata": {}, "source": [ "## 8. Foreign issuers" ] }, { "cell_type": "code", "id": "dd9fac68", "metadata": {}, "execution_count": null, "outputs": [], "source": [ "df.groupby(\"is_foreign_issuer\").size().to_frame(\"companies\")" ] }, { "cell_type": "markdown", "id": "54507809", "metadata": {}, "source": [ "## 9. Largest filers by recent filings" ] }, { "cell_type": "code", "id": "2bf7b517", "metadata": {}, "execution_count": null, "outputs": [], "source": [ "df.nlargest(15, \"filing_count_recent\")[[\"name\", \"sic_description\", \"filing_count_recent\", \"latest_filing_date\"]]" ] }, { "cell_type": "markdown", "id": "291a6744", "metadata": {}, "source": [ "## 10. Annual-report lag" ] }, { "cell_type": "code", "id": "0cd01d69", "metadata": {}, "execution_count": null, "outputs": [], "source": [ "df[\"annual_report_lag_days\"].dropna().describe().round(1).to_frame(\"days\")" ] }, { "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 }