{ "cells": [ { "cell_type": "markdown", "id": "cd5b0b5d", "metadata": {}, "source": [ "# Global Cosmetics & Personal Care\n", "\n", "Starter notebook for the Kaggle dataset in this folder. It loads `cosmetics.csv` with pandas and walks through quality checks and a first piece of analysis.\n", "\n", "**Files:** `cosmetics.csv`, `data_dictionary.csv`." ] }, { "cell_type": "markdown", "id": "0000f7f2", "metadata": {}, "source": [ "## 1. Load the data" ] }, { "cell_type": "code", "id": "05d899b7", "metadata": {}, "execution_count": null, "outputs": [], "source": [ "import pandas as pd\n", "\n", "df = pd.read_csv(\"cosmetics.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": "bd64fc81", "metadata": {}, "source": [ "## 4. Products by category group" ] }, { "cell_type": "code", "id": "17e26258", "metadata": {}, "execution_count": null, "outputs": [], "source": [ "df[\"category_group\"].value_counts().to_frame(\"products\")" ] }, { "cell_type": "markdown", "id": "06bcebda", "metadata": {}, "source": [ "## 5. Top brands" ] }, { "cell_type": "code", "id": "38e98c72", "metadata": {}, "execution_count": null, "outputs": [], "source": [ "df[\"brands\"].value_counts().head(15).to_frame(\"products\")" ] }, { "cell_type": "markdown", "id": "0b69ba1d", "metadata": {}, "source": [ "## 6. Claim prevalence" ] }, { "cell_type": "code", "id": "7b14f0d4", "metadata": {}, "execution_count": null, "outputs": [], "source": [ "for c in [\"is_vegan\", \"is_organic\", \"is_natural\", \"is_hypoallergenic\", \"is_paraben_free\", \"is_sulfate_free\"]:\n", " print(c, round((df[c].astype(str).str.lower() == \"true\").mean() * 100, 1), \"%\")" ] }, { "cell_type": "markdown", "id": "91a45a76", "metadata": {}, "source": [ "## 7. Ingredient count" ] }, { "cell_type": "code", "id": "e1bf19ad", "metadata": {}, "execution_count": null, "outputs": [], "source": [ "df[\"ingredient_count\"].dropna().clip(upper=60).hist(bins=40, figsize=(8, 4))" ] }, { "cell_type": "markdown", "id": "77de1e72", "metadata": {}, "source": [ "## 8. Category vs ingredient complexity" ] }, { "cell_type": "code", "id": "f73d22f0", "metadata": {}, "execution_count": null, "outputs": [], "source": [ "df.groupby(\"category_group\")[\"ingredient_count\"].median().sort_values().to_frame(\"median_ingredients\")" ] }, { "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 }