{ "cells": [ { "cell_type": "markdown", "id": "35dab2ea", "metadata": {}, "source": [ "# Stack Overflow Questions\n", "\n", "Starter notebook for the Kaggle dataset in this folder. It loads `stackoverflow_questions.csv` with pandas and walks through quality checks and a first piece of analysis.\n", "\n", "**Files:** `stackoverflow_questions.csv`, `data_dictionary.csv`." ] }, { "cell_type": "markdown", "id": "0000f7f2", "metadata": {}, "source": [ "## 1. Load the data" ] }, { "cell_type": "code", "id": "da08adb3", "metadata": {}, "execution_count": null, "outputs": [], "source": [ "import pandas as pd\n", "\n", "df = pd.read_csv(\"stackoverflow_questions.csv\", low_memory=False, parse_dates=[\"creation_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": "e3e67402", "metadata": {}, "source": [ "## 4. Top tags" ] }, { "cell_type": "code", "id": "38586be8", "metadata": {}, "execution_count": null, "outputs": [], "source": [ "df[\"tags\"].dropna().str.split(\";\").explode().str.strip().value_counts().head(20).to_frame(\"questions\")" ] }, { "cell_type": "markdown", "id": "d2993b8e", "metadata": {}, "source": [ "## 5. Answered share" ] }, { "cell_type": "code", "id": "5e5bcd58", "metadata": {}, "execution_count": null, "outputs": [], "source": [ "df[\"is_answered\"].value_counts(normalize=True).mul(100).round(1)" ] }, { "cell_type": "markdown", "id": "917d67b2", "metadata": {}, "source": [ "## 6. Score distribution" ] }, { "cell_type": "code", "id": "d0f52ef7", "metadata": {}, "execution_count": null, "outputs": [], "source": [ "df[\"score\"].clip(-5, 50).hist(bins=50, figsize=(8, 4))" ] }, { "cell_type": "markdown", "id": "3ce8a8d4", "metadata": {}, "source": [ "## 7. Views vs answers" ] }, { "cell_type": "code", "id": "f5299aa2", "metadata": {}, "execution_count": null, "outputs": [], "source": [ "sub = df.dropna(subset=[\"view_count\", \"answer_count\"])\n", "sub.plot.scatter(x=\"view_count\", y=\"answer_count\", s=4, alpha=0.2, figsize=(8, 5))" ] }, { "cell_type": "markdown", "id": "124bc34d", "metadata": {}, "source": [ "## 8. Body length vs score" ] }, { "cell_type": "code", "id": "29f7d101", "metadata": {}, "execution_count": null, "outputs": [], "source": [ "df.plot.scatter(x=\"body_text_length\", y=\"score\", s=3, alpha=0.2, 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 }