From 22067e496ab55332c419740006cca9faeafe1bf0 Mon Sep 17 00:00:00 2001
From: Tim Jammer <tim.jammer@sc.tu-darmstadt.de>
Date: Tue, 13 Sep 2022 13:51:59 +0200
Subject: [PATCH] updated the slides to also include solutions for the last
 exercises

---
 slides/Day2_PandasDataFrames.ipynb | 24 +++++++++++++++++++-----
 1 file changed, 19 insertions(+), 5 deletions(-)

diff --git a/slides/Day2_PandasDataFrames.ipynb b/slides/Day2_PandasDataFrames.ipynb
index 288ef4f..38a5542 100644
--- a/slides/Day2_PandasDataFrames.ipynb
+++ b/slides/Day2_PandasDataFrames.ipynb
@@ -2213,7 +2213,11 @@
    "id": "53d45569",
    "metadata": {},
    "outputs": [],
-   "source": []
+   "source": [
+    "cols=[\"sepal length\",\"sepal width\",\"petal length\",\"petal width\"]\n",
+    "df_agg= df.loc[:,cols].agg([np.min, np.max, np.mean, np.std])\n",
+    "df_agg"
+   ]
   },
   {
    "cell_type": "markdown",
@@ -2229,7 +2233,10 @@
    "id": "52a96d54",
    "metadata": {},
    "outputs": [],
-   "source": []
+   "source": [
+    "df.loc[:,cols] =((df.loc[:,cols]  - df_agg.loc['mean',:] )/ df_agg.loc['std',:])\n",
+    "df.describe()"
+   ]
   },
   {
    "cell_type": "markdown",
@@ -2263,7 +2270,9 @@
    "id": "801dd946",
    "metadata": {},
    "outputs": [],
-   "source": []
+   "source": [
+    "grouped_by_species = df.groupby(by=[\"Name\"])"
+   ]
   },
   {
    "cell_type": "code",
@@ -2271,7 +2280,12 @@
    "id": "90b8c49e",
    "metadata": {},
    "outputs": [],
-   "source": []
+   "source": [
+    "fig, axs = plt.subplots(1,3)\n",
+    "for ax, (name, group_data) in zip(axs,grouped_by_species):    \n",
+    "    group_data.boxplot(ax=ax)\n",
+    "    ax.set_title(name)"
+   ]
   },
   {
    "cell_type": "code",
@@ -2285,7 +2299,7 @@
  "metadata": {
   "celltoolbar": "Slideshow",
   "kernelspec": {
-   "display_name": "Python 3 (ipykernel)",
+   "display_name": "Python 3",
    "language": "python",
    "name": "python3"
   },
-- 
GitLab