{ "cells": [ { "cell_type": "markdown", "source": [ "# Import" ], "metadata": { "collapsed": false }, "id": "5e7a29153fb40cd" }, { "cell_type": "code", "source": [ "import pandas as pd\n", "from plotnine import ggplot, aes, geom_boxplot, stat_boxplot, theme, labs, element_blank, scale_color_manual, scale_fill_manual, geom_jitter, theme_gray\n", "import matplotlib.pyplot as plt\n", "from matplotlib.colors import to_rgba\n", "import seaborn as sns\n", "import plotly.express as px" ], "metadata": { "collapsed": false, "ExecuteTime": { "end_time": "2026-04-09T13:16:04.741003Z", "start_time": "2026-04-09T13:16:04.055170Z" } }, "id": "839093e1b76562d9", "outputs": [], "execution_count": 1 }, { "metadata": {}, "cell_type": "markdown", "source": "", "id": "3e69a9519493d086" }, { "cell_type": "markdown", "source": [ "# Data" ], "metadata": { "collapsed": false }, "id": "9d96edb3d578ee58" }, { "cell_type": "code", "source": [ "data_toy = pd.read_csv(\"toy.csv\")\n", "data_toy[\"austrian\"] = data_toy[\"austrian\"].astype(bool)\n", "data_toy[\"marital_status\"] = pd.Categorical(data_toy[\"marital_status\"], categories=[\"single\", \"divorced\", \"married\"])\n", "data_toy[\"age_cat\"] = pd.Categorical(data_toy[\"age_cat\"], categories = [\"child\", \"adolescent\", \"adult\"], ordered = True)\n", "\n", "data_toy_plot = data_toy[[\"marital_status\", \"year_birth\"]].dropna()\n", "data_toy_plot.head()" ], "metadata": { "collapsed": false, "ExecuteTime": { "end_time": "2026-04-09T13:16:04.765340Z", "start_time": "2026-04-09T13:16:04.742680Z" } }, "id": "70a6f9aa6318fdce", "outputs": [ { "data": { "text/plain": [ " marital_status year_birth\n", "0 divorced 1990.0\n", "1 single 2009.0\n", "2 single 2005.0\n", "3 single 2019.0\n", "4 married 1930.0" ], "text/html": [ "
| \n", " | marital_status | \n", "year_birth | \n", "
|---|---|---|
| 0 | \n", "divorced | \n", "1990.0 | \n", "
| 1 | \n", "single | \n", "2009.0 | \n", "
| 2 | \n", "single | \n", "2005.0 | \n", "
| 3 | \n", "single | \n", "2019.0 | \n", "
| 4 | \n", "married | \n", "1930.0 | \n", "