63
63
import pandas .core .common as com
64
64
from pandas .core .construction import create_series_with_explicit_dtype
65
65
from pandas .core .frame import DataFrame
66
- from pandas .core .generic import ABCDataFrame , ABCSeries , NDFrame , _shared_docs
66
+ from pandas .core .generic import ABCDataFrame , ABCSeries , NDFrame
67
67
from pandas .core .groupby import base
68
68
from pandas .core .groupby .groupby import (
69
69
GroupBy ,
70
+ _agg_template ,
70
71
_apply_docs ,
71
72
_transform_template ,
72
73
get_groupby ,
@@ -177,16 +178,6 @@ def _selection_name(self):
177
178
else :
178
179
return self ._selection
179
180
180
- _agg_see_also_doc = dedent (
181
- """
182
- See Also
183
- --------
184
- pandas.Series.groupby.apply
185
- pandas.Series.groupby.transform
186
- pandas.Series.aggregate
187
- """
188
- )
189
-
190
181
_agg_examples_doc = dedent (
191
182
"""
192
183
Examples
@@ -224,8 +215,7 @@ def _selection_name(self):
224
215
... )
225
216
minimum maximum
226
217
1 1 2
227
- 2 3 4
228
- """
218
+ 2 3 4"""
229
219
)
230
220
231
221
@Appender (
@@ -237,13 +227,9 @@ def apply(self, func, *args, **kwargs):
237
227
return super ().apply (func , * args , ** kwargs )
238
228
239
229
@Substitution (
240
- see_also = _agg_see_also_doc ,
241
- examples = _agg_examples_doc ,
242
- versionadded = "" ,
243
- klass = "Series" ,
244
- axis = "" ,
230
+ examples = _agg_examples_doc , klass = "Series" ,
245
231
)
246
- @Appender (_shared_docs [ "aggregate" ] )
232
+ @Appender (_agg_template )
247
233
def aggregate (
248
234
self , func = None , * args , engine = "cython" , engine_kwargs = None , ** kwargs
249
235
):
@@ -476,7 +462,7 @@ def _aggregate_named(self, func, *args, **kwargs):
476
462
477
463
return result
478
464
479
- @Substitution (klass = "Series" , selected = "A." )
465
+ @Substitution (klass = "Series" )
480
466
@Appender (_transform_template )
481
467
def transform (self , func , * args , engine = "cython" , engine_kwargs = None , ** kwargs ):
482
468
func = self ._get_cython_func (func ) or func
@@ -854,16 +840,6 @@ class DataFrameGroupBy(GroupBy[DataFrame]):
854
840
855
841
_apply_whitelist = base .dataframe_apply_whitelist
856
842
857
- _agg_see_also_doc = dedent (
858
- """
859
- See Also
860
- --------
861
- pandas.DataFrame.groupby.apply
862
- pandas.DataFrame.groupby.transform
863
- pandas.DataFrame.aggregate
864
- """
865
- )
866
-
867
843
_agg_examples_doc = dedent (
868
844
"""
869
845
Examples
@@ -928,26 +904,20 @@ class DataFrameGroupBy(GroupBy[DataFrame]):
928
904
1 1 0.590715
929
905
2 3 0.704907
930
906
931
-
932
907
- The keywords are the *output* column names
933
908
- The values are tuples whose first element is the column to select
934
909
and the second element is the aggregation to apply to that column.
935
910
Pandas provides the ``pandas.NamedAgg`` namedtuple with the fields
936
911
``['column', 'aggfunc']`` to make it clearer what the arguments are.
937
912
As usual, the aggregation can be a callable or a string alias.
938
913
939
- See :ref:`groupby.aggregate.named` for more.
940
- """
914
+ See :ref:`groupby.aggregate.named` for more."""
941
915
)
942
916
943
917
@Substitution (
944
- see_also = _agg_see_also_doc ,
945
- examples = _agg_examples_doc ,
946
- versionadded = "" ,
947
- klass = "DataFrame" ,
948
- axis = "" ,
918
+ examples = _agg_examples_doc , klass = "DataFrame" ,
949
919
)
950
- @Appender (_shared_docs [ "aggregate" ] )
920
+ @Appender (_agg_template )
951
921
def aggregate (
952
922
self , func = None , * args , engine = "cython" , engine_kwargs = None , ** kwargs
953
923
):
@@ -1467,7 +1437,7 @@ def _transform_general(
1467
1437
concatenated = concatenated .reindex (concat_index , axis = other_axis , copy = False )
1468
1438
return self ._set_result_index_ordered (concatenated )
1469
1439
1470
- @Substitution (klass = "DataFrame" , selected = "" )
1440
+ @Substitution (klass = "DataFrame" )
1471
1441
@Appender (_transform_template )
1472
1442
def transform (self , func , * args , engine = "cython" , engine_kwargs = None , ** kwargs ):
1473
1443
0 commit comments