From f21dc32e28b4452d1220777062086b3391132356 Mon Sep 17 00:00:00 2001 From: Sean Malloy Date: Thu, 1 Dec 2022 15:25:57 -0800 Subject: [PATCH 01/17] feat: adding to the function docs that transform function parameter can take a string argument --- pandas/core/groupby/groupby.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/core/groupby/groupby.py b/pandas/core/groupby/groupby.py index 497e0ef724373..c73a2d40a33e1 100644 --- a/pandas/core/groupby/groupby.py +++ b/pandas/core/groupby/groupby.py @@ -399,7 +399,7 @@ class providing the base-class of operations. Parameters ---------- -f : function +f : function, str Function to apply to each group. See the Notes section below for requirements. Can also accept a Numba JIT function with From ef6c095f90c90659c9db6c56ed3d6c05f10aae9a Mon Sep 17 00:00:00 2001 From: Sean Malloy Date: Fri, 2 Dec 2022 15:28:17 -0800 Subject: [PATCH 02/17] docs: updating docs for groupby --- pandas/core/groupby/groupby.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pandas/core/groupby/groupby.py b/pandas/core/groupby/groupby.py index c73a2d40a33e1..6d753e64e9941 100644 --- a/pandas/core/groupby/groupby.py +++ b/pandas/core/groupby/groupby.py @@ -402,7 +402,10 @@ class providing the base-class of operations. f : function, str Function to apply to each group. See the Notes section below for requirements. - Can also accept a Numba JIT function with + Accepted inputs are: + + - A String + - Numba JIT function with ``engine='numba'`` specified. If the ``'numba'`` engine is chosen, the function must be From 3b84281aea5673b2e3ba4624e2b7532895c2860a Mon Sep 17 00:00:00 2001 From: Sean Malloy Date: Sat, 3 Dec 2022 15:18:43 -0800 Subject: [PATCH 03/17] doc: updating docs to fix PR comments --- pandas/core/groupby/groupby.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/pandas/core/groupby/groupby.py b/pandas/core/groupby/groupby.py index 6d753e64e9941..7763bde8371bc 100644 --- a/pandas/core/groupby/groupby.py +++ b/pandas/core/groupby/groupby.py @@ -404,9 +404,8 @@ class providing the base-class of operations. Accepted inputs are: - - A String - - Numba JIT function with - ``engine='numba'`` specified. + - string function name + - Numba JIT function with ``engine='numba'`` specified. If the ``'numba'`` engine is chosen, the function must be a user defined function with ``values`` and ``index`` as the @@ -414,6 +413,11 @@ class providing the base-class of operations. Each group's index will be passed to the user defined function and optionally available for use. + If a string is chosen, then it needs to be the string of the + function you want to use. + + IE: ``grouped.transform("sum")`` + .. versionchanged:: 1.1.0 *args Positional arguments to pass to func. From 8f4b8c7a8f06de47ef5ee218735011167badf681 Mon Sep 17 00:00:00 2001 From: Sean Malloy Date: Sat, 3 Dec 2022 16:46:35 -0800 Subject: [PATCH 04/17] fix: fixing failing doc check --- pandas/core/groupby/groupby.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/core/groupby/groupby.py b/pandas/core/groupby/groupby.py index 0bace845940ec..a1816858df5b9 100644 --- a/pandas/core/groupby/groupby.py +++ b/pandas/core/groupby/groupby.py @@ -417,7 +417,7 @@ class providing the base-class of operations. If a string is chosen, then it needs to be the string of the function you want to use. - IE: ``grouped.transform("sum")`` + IE: ``grouped.transform("sum")``. .. versionchanged:: 1.1.0 *args From b06287ea491939ead79f91ea881df8d141b4fd8e Mon Sep 17 00:00:00 2001 From: Sean Malloy Date: Sat, 3 Dec 2022 19:39:55 -0800 Subject: [PATCH 05/17] docs: updating docs according to PR comment --- pandas/core/groupby/groupby.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/core/groupby/groupby.py b/pandas/core/groupby/groupby.py index a1816858df5b9..3c83e72a63f5e 100644 --- a/pandas/core/groupby/groupby.py +++ b/pandas/core/groupby/groupby.py @@ -417,7 +417,7 @@ class providing the base-class of operations. If a string is chosen, then it needs to be the string of the function you want to use. - IE: ``grouped.transform("sum")``. + IE: ``pd.%(klass)s = grouped.transform("sum")``. .. versionchanged:: 1.1.0 *args From f6c24f71dd496abfcbd3d27319ef0b0a71b908db Mon Sep 17 00:00:00 2001 From: Sean Malloy Date: Sat, 3 Dec 2022 22:01:04 -0800 Subject: [PATCH 06/17] docs: fixing PR comment --- pandas/core/groupby/groupby.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/core/groupby/groupby.py b/pandas/core/groupby/groupby.py index 3c83e72a63f5e..2f05cc98b033a 100644 --- a/pandas/core/groupby/groupby.py +++ b/pandas/core/groupby/groupby.py @@ -490,7 +490,7 @@ class providing the base-class of operations. Examples -------- ->>> df = pd.DataFrame({'A' : ['foo', 'bar', 'foo', 'bar', +>>> df = pd.%(klass)s({'A' : ['foo', 'bar', 'foo', 'bar', ... 'foo', 'bar'], ... 'B' : ['one', 'one', 'two', 'three', ... 'two', 'two'], From 207abd63cbc36c7fdc2024eaaebc76c1d5336168 Mon Sep 17 00:00:00 2001 From: Sean Malloy Date: Sun, 4 Dec 2022 15:05:06 -0800 Subject: [PATCH 07/17] docs: updating docs to better suit dataframes and series --- pandas/core/groupby/generic.py | 62 ++++++++++++++++++++++++++++++++-- pandas/core/groupby/groupby.py | 32 ++---------------- 2 files changed, 63 insertions(+), 31 deletions(-) diff --git a/pandas/core/groupby/generic.py b/pandas/core/groupby/generic.py index d3e37a40614b3..7c214f1b344f4 100644 --- a/pandas/core/groupby/generic.py +++ b/pandas/core/groupby/generic.py @@ -429,7 +429,32 @@ def _aggregate_named(self, func, *args, **kwargs): return result - @Substitution(klass="Series") + __examples_series_doc = dedent( + """ + ser = pd.Series( + ... [390.0, 350.0, 30.0, 20.0], + ... index=["Falcon", "Falcon", "Parrot", "Parrot"], + ... name="Max Speed") + >>> grouped = ser.groupby([1, 1, 2, 2]) + >>> grouped.transform(lambda x: (x - x.mean()) / x.std()) + Falcon 0.707107 + Falcon -0.707107 + Parrot 0.707107 + Parrot -0.707107 + Name: Max Speed, dtype: float64 + + Broadcast result of the transformation + + >>> grouped.transform(lambda x: x.max() - x.min()) + Falcon 40.0 + Falcon 40.0 + Parrot 10.0 + Parrot 10.0 + Name: Max Speed, dtype: float64 + """ + ) + + @Substitution(klass="Series", example_class="ser", example=__examples_series_doc) @Appender(_transform_template) def transform(self, func, *args, engine=None, engine_kwargs=None, **kwargs): return self._transform( @@ -1425,7 +1450,40 @@ def _transform_general(self, func, *args, **kwargs): concatenated = concatenated.reindex(concat_index, axis=other_axis, copy=False) return self._set_result_index_ordered(concatenated) - @Substitution(klass="DataFrame") + __examples_dataframe_doc = dedent( + """ + df = pd.DataFrame({'A' : ['foo', 'bar', 'foo', 'bar', + ... 'foo', 'bar'], + ... 'B' : ['one', 'one', 'two', 'three', + ... 'two', 'two'], + ... 'C' : [1, 5, 5, 2, 5, 5], + ... 'D' : [2.0, 5., 8., 1., 2., 9.]}) + >>> grouped = df.groupby('A')[['C', 'D']] + >>> grouped.transform(lambda x: (x - x.mean()) / x.std()) + C D + 0 -1.154701 -0.577350 + 1 0.577350 0.000000 + 2 0.577350 1.154701 + 3 -1.154701 -1.000000 + 4 0.577350 -0.577350 + 5 0.577350 1.000000 + + Broadcast result of the transformation + + >>> grouped.transform(lambda x: x.max() - x.min()) + C D + 0 4.0 6.0 + 1 3.0 8.0 + 2 4.0 6.0 + 3 3.0 8.0 + 4 4.0 6.0 + 5 3.0 8.0 + """ + ) + + @Substitution( + klass="DataFrame", example_class="df", example=__examples_dataframe_doc + ) @Appender(_transform_template) def transform(self, func, *args, engine=None, engine_kwargs=None, **kwargs): return self._transform( diff --git a/pandas/core/groupby/groupby.py b/pandas/core/groupby/groupby.py index 2f05cc98b033a..5482ed18b5151 100644 --- a/pandas/core/groupby/groupby.py +++ b/pandas/core/groupby/groupby.py @@ -408,6 +408,7 @@ class providing the base-class of operations. - string function name - Numba JIT function with ``engine='numba'`` specified. + Only passing a single function is supported with this engine. If the ``'numba'`` engine is chosen, the function must be a user defined function with ``values`` and ``index`` as the first and second arguments respectively in the function signature. @@ -415,9 +416,7 @@ class providing the base-class of operations. and optionally available for use. If a string is chosen, then it needs to be the string of the - function you want to use. - - IE: ``pd.%(klass)s = grouped.transform("sum")``. + groupby method you want to use. .. versionchanged:: 1.1.0 *args @@ -490,32 +489,7 @@ class providing the base-class of operations. Examples -------- ->>> df = pd.%(klass)s({'A' : ['foo', 'bar', 'foo', 'bar', -... 'foo', 'bar'], -... 'B' : ['one', 'one', 'two', 'three', -... 'two', 'two'], -... 'C' : [1, 5, 5, 2, 5, 5], -... 'D' : [2.0, 5., 8., 1., 2., 9.]}) ->>> grouped = df.groupby('A')[['C', 'D']] ->>> grouped.transform(lambda x: (x - x.mean()) / x.std()) - C D -0 -1.154701 -0.577350 -1 0.577350 0.000000 -2 0.577350 1.154701 -3 -1.154701 -1.000000 -4 0.577350 -0.577350 -5 0.577350 1.000000 - -Broadcast result of the transformation - ->>> grouped.transform(lambda x: x.max() - x.min()) - C D -0 4.0 6.0 -1 3.0 8.0 -2 4.0 6.0 -3 3.0 8.0 -4 4.0 6.0 -5 3.0 8.0 +>>> %(example)s .. versionchanged:: 1.3.0 From 90cae51f589f4a69d41a52308753f81ced25c76d Mon Sep 17 00:00:00 2001 From: Sean Malloy Date: Sun, 4 Dec 2022 17:56:03 -0800 Subject: [PATCH 08/17] docs: resolving PR comments --- pandas/core/groupby/generic.py | 13 +++++++++++++ pandas/core/groupby/groupby.py | 8 +++++--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/pandas/core/groupby/generic.py b/pandas/core/groupby/generic.py index 7c214f1b344f4..f2520eb97678a 100644 --- a/pandas/core/groupby/generic.py +++ b/pandas/core/groupby/generic.py @@ -451,6 +451,11 @@ def _aggregate_named(self, func, *args, **kwargs): Parrot 10.0 Parrot 10.0 Name: Max Speed, dtype: float64 + >>> grouped.transform("mean") + Falcon 370.0 + Falcon 370.0 + Parrot 25.0 + Parrot 25.0 """ ) @@ -543,6 +548,14 @@ def filter(self, func, dropna: bool = True, *args, **kwargs): 3 4 5 6 Name: B, dtype: int64 + >>> grouped.transform("mean") + B C + 0 3.0 4.0 + 1 4.0 5.0 + 2 3.0 4.0 + 3 4.0 5.0 + 4 3.0 4.0 + 5 4.0 5.0 """ if isinstance(func, str): wrapper = lambda x: getattr(x, func)(*args, **kwargs) diff --git a/pandas/core/groupby/groupby.py b/pandas/core/groupby/groupby.py index 5482ed18b5151..5e2ae4bfed18f 100644 --- a/pandas/core/groupby/groupby.py +++ b/pandas/core/groupby/groupby.py @@ -405,7 +405,9 @@ class providing the base-class of operations. Accepted inputs are: - - string function name + - String function name + - Standard Python function + - User defined functions IE ``lambda x: x.sum()`` - Numba JIT function with ``engine='numba'`` specified. Only passing a single function is supported with this engine. @@ -415,8 +417,8 @@ class providing the base-class of operations. Each group's index will be passed to the user defined function and optionally available for use. - If a string is chosen, then it needs to be the string of the - groupby method you want to use. + If a string is chosen, then it needs to be the string name + of the groupby method you want to use. .. versionchanged:: 1.1.0 *args From 36f31f14bb69f85ae30c012b8168849d0984ce9f Mon Sep 17 00:00:00 2001 From: Sean Malloy Date: Mon, 5 Dec 2022 17:30:55 -0800 Subject: [PATCH 09/17] docs: fixing PR check failure --- pandas/core/groupby/generic.py | 2 +- pandas/core/groupby/groupby.py | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/pandas/core/groupby/generic.py b/pandas/core/groupby/generic.py index f2520eb97678a..57c7d96f544eb 100644 --- a/pandas/core/groupby/generic.py +++ b/pandas/core/groupby/generic.py @@ -1491,7 +1491,7 @@ def _transform_general(self, func, *args, **kwargs): 3 3.0 8.0 4 4.0 6.0 5 3.0 8.0 - """ + """ ) @Substitution( diff --git a/pandas/core/groupby/groupby.py b/pandas/core/groupby/groupby.py index 5e2ae4bfed18f..45b50a7f8deaf 100644 --- a/pandas/core/groupby/groupby.py +++ b/pandas/core/groupby/groupby.py @@ -492,7 +492,6 @@ class providing the base-class of operations. -------- >>> %(example)s - .. versionchanged:: 1.3.0 The resulting dtype will reflect the return value of the passed ``func``, From 9223b59e6aac77dc0a12eb8585ce1e8e0c9f52d4 Mon Sep 17 00:00:00 2001 From: Sean Malloy Date: Mon, 5 Dec 2022 17:41:00 -0800 Subject: [PATCH 10/17] docs: resolving PR comments --- pandas/core/groupby/generic.py | 23 +++++++++++------------ pandas/core/groupby/groupby.py | 5 ++--- 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/pandas/core/groupby/generic.py b/pandas/core/groupby/generic.py index a42f567b90e8e..c8efef39996b5 100644 --- a/pandas/core/groupby/generic.py +++ b/pandas/core/groupby/generic.py @@ -457,7 +457,7 @@ def _aggregate_named(self, func, *args, **kwargs): """ ) - @Substitution(klass="Series", example_class="ser", example=__examples_series_doc) + @Substitution(klass="Series", example=__examples_series_doc) @Appender(_transform_template) def transform(self, func, *args, engine=None, engine_kwargs=None, **kwargs): return self._transform( @@ -546,14 +546,6 @@ def filter(self, func, dropna: bool = True, *args, **kwargs): 3 4 5 6 Name: B, dtype: int64 - >>> grouped.transform("mean") - B C - 0 3.0 4.0 - 1 4.0 5.0 - 2 3.0 4.0 - 3 4.0 5.0 - 4 3.0 4.0 - 5 4.0 5.0 """ if isinstance(func, str): wrapper = lambda x: getattr(x, func)(*args, **kwargs) @@ -1471,12 +1463,19 @@ def _transform_general(self, func, *args, **kwargs): 3 3.0 8.0 4 4.0 6.0 5 3.0 8.0 + + >>> grouped.transform("mean") + B C + 0 3.666667 4.0 + 1 4.000000 5.0 + 2 3.666667 4.0 + 3 4.000000 5.0 + 4 3.666667 4.0 + 5 4.000000 5.0 """ ) - @Substitution( - klass="DataFrame", example_class="df", example=__examples_dataframe_doc - ) + @Substitution(klass="DataFrame", example=__examples_dataframe_doc) @Appender(_transform_template) def transform(self, func, *args, engine=None, engine_kwargs=None, **kwargs): return self._transform( diff --git a/pandas/core/groupby/groupby.py b/pandas/core/groupby/groupby.py index e043092573ddc..eeef5d38005c4 100644 --- a/pandas/core/groupby/groupby.py +++ b/pandas/core/groupby/groupby.py @@ -405,8 +405,7 @@ class providing the base-class of operations. Accepted inputs are: - String function name - - Standard Python function - - User defined functions IE ``lambda x: x.sum()`` + - Python function - Numba JIT function with ``engine='numba'`` specified. Only passing a single function is supported with this engine. @@ -416,7 +415,7 @@ class providing the base-class of operations. Each group's index will be passed to the user defined function and optionally available for use. - If a string is chosen, then it needs to be the string name + If a string is chosen, then it needs to be the name of the groupby method you want to use. .. versionchanged:: 1.1.0 From 0651cdca5de25758d5f9b505dea9e3315f69b571 Mon Sep 17 00:00:00 2001 From: Sean Malloy Date: Mon, 5 Dec 2022 20:28:06 -0800 Subject: [PATCH 11/17] docs: fixing issue with docstring validation --- pandas/core/groupby/generic.py | 4 ++-- pandas/core/groupby/groupby.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pandas/core/groupby/generic.py b/pandas/core/groupby/generic.py index c8efef39996b5..807336c18c215 100644 --- a/pandas/core/groupby/generic.py +++ b/pandas/core/groupby/generic.py @@ -429,7 +429,7 @@ def _aggregate_named(self, func, *args, **kwargs): __examples_series_doc = dedent( """ - ser = pd.Series( + >>> ser = pd.Series( ... [390.0, 350.0, 30.0, 20.0], ... index=["Falcon", "Falcon", "Parrot", "Parrot"], ... name="Max Speed") @@ -1437,7 +1437,7 @@ def _transform_general(self, func, *args, **kwargs): __examples_dataframe_doc = dedent( """ - df = pd.DataFrame({'A' : ['foo', 'bar', 'foo', 'bar', + >>> df = pd.DataFrame({'A' : ['foo', 'bar', 'foo', 'bar', ... 'foo', 'bar'], ... 'B' : ['one', 'one', 'two', 'three', ... 'two', 'two'], diff --git a/pandas/core/groupby/groupby.py b/pandas/core/groupby/groupby.py index eeef5d38005c4..ebb542e6115fb 100644 --- a/pandas/core/groupby/groupby.py +++ b/pandas/core/groupby/groupby.py @@ -488,7 +488,7 @@ class providing the base-class of operations. Examples -------- ->>> %(example)s +%(example)s .. versionchanged:: 1.3.0 The resulting dtype will reflect the return value of the passed ``func``, From a5f84df758424818b8172617f4f13b1c7fd736fe Mon Sep 17 00:00:00 2001 From: Sean Malloy Date: Mon, 5 Dec 2022 20:41:25 -0800 Subject: [PATCH 12/17] docs: fixing doctest failures --- pandas/core/groupby/generic.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pandas/core/groupby/generic.py b/pandas/core/groupby/generic.py index 807336c18c215..ae64cacd28183 100644 --- a/pandas/core/groupby/generic.py +++ b/pandas/core/groupby/generic.py @@ -448,7 +448,6 @@ def _aggregate_named(self, func, *args, **kwargs): Falcon 40.0 Parrot 10.0 Parrot 10.0 - Name: Max Speed, dtype: float64 >>> grouped.transform("mean") Falcon 370.0 Falcon 370.0 @@ -1465,7 +1464,7 @@ def _transform_general(self, func, *args, **kwargs): 5 3.0 8.0 >>> grouped.transform("mean") - B C + C D 0 3.666667 4.0 1 4.000000 5.0 2 3.666667 4.0 From 330605749b7e946ce6ac8e21f2aad8e6780f4050 Mon Sep 17 00:00:00 2001 From: Sean Malloy Date: Mon, 5 Dec 2022 21:40:04 -0800 Subject: [PATCH 13/17] docs: fixing some issues in the docstrings checks --- pandas/core/groupby/generic.py | 2 ++ pandas/core/groupby/groupby.py | 1 - 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/pandas/core/groupby/generic.py b/pandas/core/groupby/generic.py index ae64cacd28183..0ffef1c0612eb 100644 --- a/pandas/core/groupby/generic.py +++ b/pandas/core/groupby/generic.py @@ -448,6 +448,8 @@ def _aggregate_named(self, func, *args, **kwargs): Falcon 40.0 Parrot 10.0 Parrot 10.0 + Name: Max Speed, dtype: float64 + >>> grouped.transform("mean") Falcon 370.0 Falcon 370.0 diff --git a/pandas/core/groupby/groupby.py b/pandas/core/groupby/groupby.py index ebb542e6115fb..e4bb93ed32182 100644 --- a/pandas/core/groupby/groupby.py +++ b/pandas/core/groupby/groupby.py @@ -487,7 +487,6 @@ class providing the base-class of operations. Examples -------- - %(example)s .. versionchanged:: 1.3.0 From e7681ec81ef5052b84d8ea8c6f94aabc94c66fa8 Mon Sep 17 00:00:00 2001 From: Sean Malloy Date: Mon, 5 Dec 2022 21:55:18 -0800 Subject: [PATCH 14/17] docs: adding in some missing docs for docstest check --- pandas/core/groupby/generic.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pandas/core/groupby/generic.py b/pandas/core/groupby/generic.py index 0ffef1c0612eb..5b3aced55692a 100644 --- a/pandas/core/groupby/generic.py +++ b/pandas/core/groupby/generic.py @@ -455,6 +455,7 @@ def _aggregate_named(self, func, *args, **kwargs): Falcon 370.0 Parrot 25.0 Parrot 25.0 + Name: Max Speed, dtype: float64 """ ) From 4b5067d3376621bfa725e849bab1c628680551fb Mon Sep 17 00:00:00 2001 From: Sean Malloy Date: Mon, 5 Dec 2022 23:52:59 -0800 Subject: [PATCH 15/17] docs: fixing doctest check failure --- pandas/core/groupby/generic.py | 26 ++++++++++++++++++++++++++ pandas/core/groupby/groupby.py | 13 ------------- 2 files changed, 26 insertions(+), 13 deletions(-) diff --git a/pandas/core/groupby/generic.py b/pandas/core/groupby/generic.py index 5b3aced55692a..5fce8fd28e652 100644 --- a/pandas/core/groupby/generic.py +++ b/pandas/core/groupby/generic.py @@ -456,6 +456,18 @@ def _aggregate_named(self, func, *args, **kwargs): Parrot 25.0 Parrot 25.0 Name: Max Speed, dtype: float64 + + .. versionchanged:: 1.3.0 + + The resulting dtype will reflect the return value of the passed ``func``, + for example: + + >>> grouped.transform(lambda x: x.astype(int).max()) + Falcon 390 + Falcon 390 + Parrot 30 + Parrot 30 + Name: Max Speed, dtype: int64 """ ) @@ -1474,6 +1486,20 @@ def _transform_general(self, func, *args, **kwargs): 3 4.000000 5.0 4 3.666667 4.0 5 4.000000 5.0 + + .. versionchanged:: 1.3.0 + + The resulting dtype will reflect the return value of the passed ``func``, + for example: + + >>> grouped.transform(lambda x: x.astype(int).max()) + C D + 0 5 8 + 1 5 9 + 2 5 8 + 3 5 9 + 4 5 8 + 5 5 9 """ ) diff --git a/pandas/core/groupby/groupby.py b/pandas/core/groupby/groupby.py index e4bb93ed32182..cecb8ca84d415 100644 --- a/pandas/core/groupby/groupby.py +++ b/pandas/core/groupby/groupby.py @@ -488,19 +488,6 @@ class providing the base-class of operations. Examples -------- %(example)s -.. versionchanged:: 1.3.0 - - The resulting dtype will reflect the return value of the passed ``func``, - for example: - ->>> grouped.transform(lambda x: x.astype(int).max()) - C D -0 5 8 -1 5 9 -2 5 8 -3 5 9 -4 5 8 -5 5 9 """ _agg_template = """ From 0ed0d365021fbc7c05577ea023c18f4159b5b310 Mon Sep 17 00:00:00 2001 From: Sean Malloy Date: Tue, 6 Dec 2022 02:07:41 -0800 Subject: [PATCH 16/17] docs: fixing docstring validation check failure --- pandas/core/groupby/groupby.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pandas/core/groupby/groupby.py b/pandas/core/groupby/groupby.py index cecb8ca84d415..a82df4643e833 100644 --- a/pandas/core/groupby/groupby.py +++ b/pandas/core/groupby/groupby.py @@ -487,8 +487,7 @@ class providing the base-class of operations. Examples -------- -%(example)s -""" +%(example)s""" _agg_template = """ Aggregate using one or more operations over the specified axis. From 04d48f285b9019c71ba77e52170dc69e3c636eee Mon Sep 17 00:00:00 2001 From: Sean Malloy Date: Thu, 8 Dec 2022 14:15:08 -0800 Subject: [PATCH 17/17] docs: updating docs according to PR comment --- pandas/core/groupby/groupby.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/core/groupby/groupby.py b/pandas/core/groupby/groupby.py index a82df4643e833..16b43257bc242 100644 --- a/pandas/core/groupby/groupby.py +++ b/pandas/core/groupby/groupby.py @@ -404,7 +404,7 @@ class providing the base-class of operations. Accepted inputs are: - - String function name + - String - Python function - Numba JIT function with ``engine='numba'`` specified.