From 1fb57681783913fffb7b09fbbce83609262bf484 Mon Sep 17 00:00:00 2001 From: Michiel Cottaar Date: Tue, 19 Jan 2021 15:07:09 +0000 Subject: [PATCH] avoiding weird error when using custom mad --- applications/pandas/pandas.ipynb | 4 ++-- applications/pandas/pandas.md | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/applications/pandas/pandas.ipynb b/applications/pandas/pandas.ipynb index 69e390f..1245aae 100644 --- a/applications/pandas/pandas.ipynb +++ b/applications/pandas/pandas.ipynb @@ -963,7 +963,7 @@ "metadata": {}, "outputs": [], "source": [ - "titanic.groupby(['class', 'survived']).aggregate((np.median, mad))" + "titanic.groupby(['class', 'survived']).aggregate((np.median, 'mad'))" ] }, { @@ -984,7 +984,7 @@ "metadata": {}, "outputs": [], "source": [ - "df_full = titanic.groupby(['class', 'survived']).aggregate((np.median, mad))" + "df_full = titanic.groupby(['class', 'survived']).aggregate((np.median, 'mad'))" ] }, { diff --git a/applications/pandas/pandas.md b/applications/pandas/pandas.md index d7914fb..76dd30c 100644 --- a/applications/pandas/pandas.md +++ b/applications/pandas/pandas.md @@ -462,7 +462,7 @@ titanic.groupby(['class', pd.cut(titanic.age, bins=(0, 18, 50, np.inf))]).mean() We can use the `aggregate` method to apply a different function to each series ``` -titanic.groupby(['class', 'survived']).aggregate((np.median, mad)) +titanic.groupby(['class', 'survived']).aggregate((np.median, 'mad')) ``` Note that both the index (on the left) and the column names (on the top) now @@ -473,7 +473,7 @@ The short version is that columns can be selected using direct indexing (as discussed above) ``` -df_full = titanic.groupby(['class', 'survived']).aggregate((np.median, mad)) +df_full = titanic.groupby(['class', 'survived']).aggregate((np.median, 'mad')) ``` ``` -- GitLab