{ "cells": [ { "cell_type": "markdown", "id": "59cd9c4a", "metadata": {}, "source": [ "# World Language Structures — WALS Typological Atlas\n", "\n", "Starter notebook for the Kaggle dataset in this folder. It loads `world_languages.csv` with pandas and walks through quality checks and a first piece of analysis.\n", "\n", "**Files:** `world_languages.csv`, `data_dictionary.csv`." ] }, { "cell_type": "markdown", "id": "0000f7f2", "metadata": {}, "source": [ "## 1. Load the data" ] }, { "cell_type": "code", "id": "2b1369a2", "metadata": {}, "execution_count": null, "outputs": [], "source": [ "import pandas as pd\n", "\n", "df = pd.read_csv(\"world_languages.csv\", low_memory=False)\n", "print(df.shape)\n", "print(\"features:\", sum(c.startswith(\"wals_\") and c != \"wals_id\" for c in df.columns))" ] }, { "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": "567a5579", "metadata": {}, "source": [ "## 4. Languages per macroarea" ] }, { "cell_type": "code", "id": "e44a119c", "metadata": {}, "execution_count": null, "outputs": [], "source": [ "df[\"macroarea\"].value_counts().plot(kind=\"bar\", figsize=(9, 4))" ] }, { "cell_type": "markdown", "id": "b1d376a8", "metadata": {}, "source": [ "## 5. Largest language families" ] }, { "cell_type": "code", "id": "e5f45f5d", "metadata": {}, "execution_count": null, "outputs": [], "source": [ "df[\"family\"].value_counts().head(15).plot(kind=\"bar\", figsize=(11, 4))" ] }, { "cell_type": "markdown", "id": "cf88f770", "metadata": {}, "source": [ "## 6. A single feature" ] }, { "cell_type": "code", "id": "c193db5b", "metadata": {}, "execution_count": null, "outputs": [], "source": [ "df[\"wals_81a_order_of_subject_object_and_verb\"].value_counts(dropna=False).head(12)" ] }, { "cell_type": "markdown", "id": "f184d300", "metadata": {}, "source": [ "## 7. Documentation coverage" ] }, { "cell_type": "code", "id": "983ce459", "metadata": {}, "execution_count": null, "outputs": [], "source": [ "df[\"features_answered\"].hist(bins=40, figsize=(9, 4))" ] }, { "cell_type": "markdown", "id": "7f7f4960", "metadata": {}, "source": [ "## 8. Feature matrix correlation" ] }, { "cell_type": "code", "id": "33e533e5", "metadata": {}, "execution_count": null, "outputs": [], "source": [ "feat = [c for c in df.columns if c.startswith(\"wals_\")]\n", "codes = df[feat].apply(lambda s: s.astype(\"category\").cat.codes)\n", "corr = codes.corr()\n", "corr.iloc[:40, :40]" ] }, { "cell_type": "markdown", "id": "e3a59c25", "metadata": {}, "source": [ "## 9. Word-order profile" ] }, { "cell_type": "code", "id": "74a0dc04", "metadata": {}, "execution_count": null, "outputs": [], "source": [ "order = [c for c in df.columns if \"order_of\" in c][:6]\n", "df[order].describe()" ] }, { "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 }