From 31ac01bec2292f6c30f5714ed90efdbef46ce9fd Mon Sep 17 00:00:00 2001 From: vladu Date: Thu, 18 Mar 2021 15:01:58 -0500 Subject: [PATCH 1/2] DOC: Fix documentation for DataFrame.groupby.transform This should no longer reference "Series" transforms. --- pandas/core/groupby/groupby.py | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/pandas/core/groupby/groupby.py b/pandas/core/groupby/groupby.py index 979c7aa990184..c8105e8db2046 100644 --- a/pandas/core/groupby/groupby.py +++ b/pandas/core/groupby/groupby.py @@ -119,19 +119,19 @@ class providing the base-class of operations. _apply_docs = { "template": """ - Apply function `func` group-wise and combine the results together. + Apply function ``func`` group-wise and combine the results together. - The function passed to `apply` must take a {input} as its first - argument and return a DataFrame, Series or scalar. `apply` will + The function passed to ``apply`` must take a {input} as its first + argument and return a DataFrame, Series or scalar. ``apply`` will then take care of combining the results back together into a single - dataframe or series. `apply` is therefore a highly flexible + dataframe or series. ``apply`` is therefore a highly flexible grouping method. - While `apply` is a very flexible method, its downside is that + While ``apply`` is a very flexible method, its downside is that using it can be quite a bit slower than using more specific methods - like `agg` or `transform`. Pandas offers a wide range of method that will - be much faster than using `apply` for their specific purposes, so try to - use them before reaching for `apply`. + like ``agg`` or ``transform``. Pandas offers a wide range of method that will + be much faster than using ``apply`` for their specific purposes, so try to + use them before reaching for ``apply``. Parameters ---------- @@ -140,7 +140,7 @@ class providing the base-class of operations. returns a dataframe, a series or a scalar. In addition the callable may take positional and keyword arguments. args, kwargs : tuple and dict - Optional positional and keyword arguments to pass to `func`. + Optional positional and keyword arguments to pass to ``func``. Returns ------- @@ -157,7 +157,7 @@ class providing the base-class of operations. Notes ----- - In the current implementation `apply` calls `func` twice on the + In the current implementation ``apply`` calls `func` twice on the first group to decide whether it can take a fast or slow code path. This can lead to unexpected behavior if `func` has side-effects, as they will take effect twice for the first @@ -350,12 +350,12 @@ class providing the base-class of operations. See Also -------- -%(klass)s.groupby.apply : Apply function func group-wise - and combine the results together. +%(klass)s.groupby.apply : Apply function ``func`` group-wise and combine + the results together. %(klass)s.groupby.aggregate : Aggregate using one or more operations over the specified axis. -%(klass)s.transform : Transforms the Series on each group - based on the given function. +%(klass)s.transform : Call ``func`` on self producing a %(klass)s with + transformed values. Notes ----- From 48d50118323b12b92494d7db1d524a61774edc06 Mon Sep 17 00:00:00 2001 From: vladu Date: Thu, 18 Mar 2021 15:25:48 -0500 Subject: [PATCH 2/2] DOC: One more little fix to groupby.apply function doc, for consistency. --- pandas/core/groupby/groupby.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pandas/core/groupby/groupby.py b/pandas/core/groupby/groupby.py index c8105e8db2046..f2f0ec39c2f6b 100644 --- a/pandas/core/groupby/groupby.py +++ b/pandas/core/groupby/groupby.py @@ -157,9 +157,9 @@ class providing the base-class of operations. Notes ----- - In the current implementation ``apply`` calls `func` twice on the + In the current implementation ``apply`` calls ``func`` twice on the first group to decide whether it can take a fast or slow code - path. This can lead to unexpected behavior if `func` has + path. This can lead to unexpected behavior if ``func`` has side-effects, as they will take effect twice for the first group.