Skip to content

Commit fd54af4

Browse files
committed
Reordered incorrect orderings on docstrings. Moved Notes section out of shared doc and into individual occurences to avoid incorrect order of Notes and See Also sections.
1 parent cabe062 commit fd54af4

File tree

7 files changed

+100
-65
lines changed

7 files changed

+100
-65
lines changed

pandas/core/frame.py

+13-8
Original file line numberDiff line numberDiff line change
@@ -6051,12 +6051,17 @@ def _gotitem(self,
60516051
--------
60526052
DataFrame.apply : Perform any type of operations.
60536053
DataFrame.transform : Perform transformation type operations.
6054-
pandas.core.groupby.GroupBy : Perform operations over groups.
6055-
pandas.core.resample.Resampler : Perform operations over resampled bins.
6056-
pandas.core.window.Rolling : Perform operations over rolling window.
6057-
pandas.core.window.Expanding : Perform operations over expanding window.
6058-
pandas.core.window.EWM : Perform operation over exponential weighted
6059-
window.
6054+
core.groupby.GroupBy : Perform operations over groups.
6055+
core.resample.Resampler : Perform operations over resampled bins.
6056+
core.window.Rolling : Perform operations over rolling window.
6057+
core.window.Expanding : Perform operations over expanding window.
6058+
core.window.EWM : Perform operation over exponential weighted window.
6059+
6060+
Notes
6061+
-----
6062+
`agg` is an alias for `aggregate`. Use the alias.
6063+
6064+
A passed user-defined-function will be passed a Series for evaluation.
60606065
60616066
Examples
60626067
--------
@@ -6075,7 +6080,7 @@ def _gotitem(self,
60756080
60766081
Different aggregations per column.
60776082
6078-
>>> df.agg({'A' : ['sum', 'min'], 'B' : ['min', 'max']})
6083+
>>> df.agg({'A': ['sum', 'min'], 'B': ['min', 'max']})
60796084
A B
60806085
max NaN 8.0
60816086
min 1.0 2.0
@@ -6091,10 +6096,10 @@ def _gotitem(self,
60916096
dtype: float64
60926097
""")
60936098

6099+
@Appender(_agg_doc)
60946100
@Appender(_shared_docs['aggregate'] % dict(
60956101
versionadded='.. versionadded:: 0.20.0',
60966102
**_shared_doc_kwargs))
6097-
@Appender(_agg_doc)
60986103
def aggregate(self, func, axis=0, *args, **kwargs):
60996104
axis = self._get_axis_number(axis)
61006105

pandas/core/generic.py

-6
Original file line numberDiff line numberDiff line change
@@ -4925,12 +4925,6 @@ def pipe(self, func, *args, **kwargs):
49254925
if DataFrame.agg is called with several functions, returns a DataFrame
49264926
if Series.agg is called with single function, returns a scalar
49274927
if Series.agg is called with several functions, returns a Series
4928-
4929-
Notes
4930-
-----
4931-
`agg` is an alias for `aggregate`. Use the alias.
4932-
4933-
A passed user-defined-function will be passed a Series for evaluation.
49344928
""")
49354929

49364930
_shared_docs['transform'] = ("""

pandas/core/groupby/generic.py

+21-11
Original file line numberDiff line numberDiff line change
@@ -707,9 +707,20 @@ def _selection_name(self):
707707
return self._selection
708708

709709
_agg_doc = dedent("""
710-
Examples
710+
See Also
711711
--------
712+
pandas.Series.groupby.apply
713+
pandas.Series.groupby.transform
714+
pandas.Series.aggregate
715+
716+
Notes
717+
-----
718+
`agg` is an alias for `aggregate`. Use the alias.
712719
720+
A passed user-defined-function will be passed a Series for evaluation.
721+
722+
Examples
723+
--------
713724
>>> s = pd.Series([1, 2, 3, 4])
714725
715726
>>> s
@@ -733,13 +744,6 @@ def _selection_name(self):
733744
min max
734745
1 1 2
735746
2 3 4
736-
737-
See Also
738-
--------
739-
pandas.Series.groupby.apply
740-
pandas.Series.groupby.transform
741-
pandas.Series.aggregate
742-
743747
""")
744748

745749
@Appender(_apply_docs['template']
@@ -1249,9 +1253,15 @@ class DataFrameGroupBy(NDFrameGroupBy):
12491253
_agg_doc = dedent("""
12501254
See Also
12511255
--------
1252-
pandas.DataFrame.groupby.apply
1253-
pandas.DataFrame.groupby.transform
1254-
pandas.DataFrame.aggregate
1256+
DataFrame.groupby.apply
1257+
DataFrame.groupby.transform
1258+
DataFrame.aggregate
1259+
1260+
Notes
1261+
-----
1262+
`agg` is an alias for `aggregate`. Use the alias.
1263+
1264+
A passed user-defined-function will be passed a Series for evaluation.
12551265
12561266
Examples
12571267
--------

pandas/core/groupby/groupby.py

+5-8
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ class providing the base-class of operations.
4444
_common_see_also = """
4545
See Also
4646
--------
47-
pandas.Series.%(name)s
48-
pandas.DataFrame.%(name)s
49-
pandas.Panel.%(name)s
47+
Series.%(name)s
48+
DataFrame.%(name)s
49+
Panel.%(name)s
5050
"""
5151

5252
_apply_docs = dict(
@@ -2048,9 +2048,7 @@ def head(self, n=5):
20482048
20492049
Examples
20502050
--------
2051-
2052-
>>> df = pd.DataFrame([[1, 2], [1, 4], [5, 6]],
2053-
columns=['A', 'B'])
2051+
>>> df = pd.DataFrame([[1, 2], [1, 4], [5, 6]], columns=['A', 'B'])
20542052
>>> df.groupby('A', as_index=False).head(1)
20552053
A B
20562054
0 1 2
@@ -2078,8 +2076,7 @@ def tail(self, n=5):
20782076
Examples
20792077
--------
20802078
2081-
>>> df = pd.DataFrame([['a', 1], ['a', 2], ['b', 1], ['b', 2]],
2082-
columns=['A', 'B'])
2079+
>>> df = pd.DataFrame([['a', 1], ['a', 2], ['b', 1], ['b', 2]], columns=['A', 'B'])
20832080
>>> df.groupby('A').tail(1)
20842081
A B
20852082
1 a 2

pandas/core/resample.py

+13-9
Original file line numberDiff line numberDiff line change
@@ -214,14 +214,19 @@ def pipe(self, func, *args, **kwargs):
214214
_agg_doc = dedent("""
215215
See Also
216216
--------
217-
pandas.DataFrame.groupby.aggregate
218-
pandas.DataFrame.resample.transform
219-
pandas.DataFrame.aggregate
217+
DataFrame.groupby.aggregate
218+
DataFrame.resample.transform
219+
DataFrame.aggregate
220+
221+
Notes
222+
-----
223+
`agg` is an alias for `aggregate`. Use the alias.
224+
225+
A passed user-defined-function will be passed a Series for evaluation.
220226
221227
Examples
222228
--------
223-
>>> s = pd.Series([1,2,3,4,5],
224-
index=pd.date_range('20130101', periods=5,freq='s'))
229+
>>> s = pd.Series([1, 2, 3, 4, 5], index=pd.date_range('20130101', periods=5, freq='s'))
225230
2013-01-01 00:00:00 1
226231
2013-01-01 00:00:01 2
227232
2013-01-01 00:00:02 3
@@ -239,25 +244,24 @@ def pipe(self, func, *args, **kwargs):
239244
2013-01-01 00:00:04 5
240245
Freq: 2S, dtype: int64
241246
242-
>>> r.agg(['sum','mean','max'])
247+
>>> r.agg(['sum', 'mean', 'max'])
243248
sum mean max
244249
2013-01-01 00:00:00 3 1.5 2
245250
2013-01-01 00:00:02 7 3.5 4
246251
2013-01-01 00:00:04 5 5.0 5
247252
248-
>>> r.agg({'result' : lambda x: x.mean() / x.std(),
249-
'total' : np.sum})
253+
>>> r.agg({'result': lambda x: x.mean() / x.std(), 'total': np.sum})
250254
total result
251255
2013-01-01 00:00:00 3 2.121320
252256
2013-01-01 00:00:02 7 4.949747
253257
2013-01-01 00:00:04 5 NaN
254258
""")
255259

260+
@Appender(_agg_doc)
256261
@Appender(_shared_docs['aggregate'] % dict(
257262
klass='DataFrame',
258263
versionadded='',
259264
axis=''))
260-
@Appender(_agg_doc)
261265
def aggregate(self, func, *args, **kwargs):
262266

263267
self._set_binner()

pandas/core/series.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -3281,6 +3281,12 @@ def _gotitem(self, key, ndim, subset=None):
32813281
Series.apply : Invoke function on a Series.
32823282
Series.transform : Transform function producing
32833283
a Series with like indexes.
3284+
3285+
Notes
3286+
-----
3287+
`agg` is an alias for `aggregate`. Use the alias.
3288+
3289+
A passed user-defined-function will be passed a Series for evaluation.
32843290
32853291
Examples
32863292
--------
@@ -3302,10 +3308,10 @@ def _gotitem(self, key, ndim, subset=None):
33023308
dtype: int64
33033309
""")
33043310

3311+
@Appender(_agg_doc)
33053312
@Appender(generic._shared_docs['aggregate'] % dict(
33063313
versionadded='.. versionadded:: 0.20.0',
33073314
**_shared_doc_kwargs))
3308-
@Appender(_agg_doc)
33093315
def aggregate(self, func, axis=0, *args, **kwargs):
33103316
# Validate the axis parameter
33113317
self._get_axis_number(axis)

pandas/core/window.py

+41-22
Original file line numberDiff line numberDiff line change
@@ -694,9 +694,19 @@ def f(arg, *args, **kwargs):
694694
return self._wrap_results(results, blocks, obj)
695695

696696
_agg_doc = dedent("""
697-
Examples
697+
See Also
698698
--------
699+
pandas.DataFrame.rolling.aggregate
700+
pandas.DataFrame.aggregate
701+
702+
Notes
703+
-----
704+
`agg` is an alias for `aggregate`. Use the alias.
699705
706+
A passed user-defined-function will be passed a Series for evaluation.
707+
708+
Examples
709+
--------
700710
>>> df = pd.DataFrame(np.random.randn(10, 3), columns=['A', 'B', 'C'])
701711
>>> df
702712
A B C
@@ -723,12 +733,6 @@ def f(arg, *args, **kwargs):
723733
7 0.906020 1.283573 0.085482
724734
8 -0.096361 0.818139 0.472290
725735
9 0.070889 0.134399 -0.031308
726-
727-
See Also
728-
--------
729-
pandas.DataFrame.rolling.aggregate
730-
pandas.DataFrame.aggregate
731-
732736
""")
733737

734738
@Appender(_agg_doc)
@@ -1598,12 +1602,17 @@ def _validate_freq(self):
15981602
_agg_doc = dedent("""
15991603
See Also
16001604
--------
1601-
pandas.Series.rolling
1602-
pandas.DataFrame.rolling
1605+
Series.rolling
1606+
DataFrame.rolling
1607+
1608+
Notes
1609+
-----
1610+
`agg` is an alias for `aggregate`. Use the alias.
1611+
1612+
A passed user-defined-function will be passed a Series for evaluation.
16031613
16041614
Examples
16051615
--------
1606-
16071616
>>> df = pd.DataFrame(np.random.randn(10, 3), columns=['A', 'B', 'C'])
16081617
>>> df
16091618
A B C
@@ -1631,7 +1640,7 @@ def _validate_freq(self):
16311640
8 -0.289082 2.454418 1.416871
16321641
9 0.212668 0.403198 -0.093924
16331642
1634-
>>> df.rolling(3).agg({'A':'sum', 'B':'min'})
1643+
>>> df.rolling(3).agg({'A': 'sum', 'B': 'min'})
16351644
A B
16361645
0 NaN NaN
16371646
1 NaN NaN
@@ -1645,11 +1654,11 @@ def _validate_freq(self):
16451654
9 0.212668 -1.647453
16461655
""")
16471656

1657+
@Appender(_agg_doc)
16481658
@Appender(_shared_docs['aggregate'] % dict(
16491659
versionadded='',
16501660
klass='Series/DataFrame',
16511661
axis=''))
1652-
@Appender(_agg_doc)
16531662
def aggregate(self, arg, *args, **kwargs):
16541663
return super(Rolling, self).aggregate(arg, *args, **kwargs)
16551664

@@ -1886,13 +1895,18 @@ def _get_window(self, other=None):
18861895
_agg_doc = dedent("""
18871896
See Also
18881897
--------
1889-
pandas.DataFrame.expanding.aggregate
1890-
pandas.DataFrame.rolling.aggregate
1891-
pandas.DataFrame.aggregate
1898+
DataFrame.expanding.aggregate
1899+
DataFrame.rolling.aggregate
1900+
DataFrame.aggregate
1901+
1902+
Notes
1903+
-----
1904+
`agg` is an alias for `aggregate`. Use the alias.
1905+
1906+
A passed user-defined-function will be passed a Series for evaluation.
18921907
18931908
Examples
18941909
--------
1895-
18961910
>>> df = pd.DataFrame(np.random.randn(10, 3), columns=['A', 'B', 'C'])
18971911
>>> df
18981912
A B C
@@ -1921,11 +1935,11 @@ def _get_window(self, other=None):
19211935
9 -0.286980 0.618493 -0.694496
19221936
""")
19231937

1938+
@Appender(_agg_doc)
19241939
@Appender(_shared_docs['aggregate'] % dict(
19251940
versionadded='',
19261941
klass='Series/DataFrame',
19271942
axis=''))
1928-
@Appender(_agg_doc)
19291943
def aggregate(self, arg, *args, **kwargs):
19301944
return super(Expanding, self).aggregate(arg, *args, **kwargs)
19311945

@@ -2185,9 +2199,18 @@ def _constructor(self):
21852199
return EWM
21862200

21872201
_agg_doc = dedent("""
2188-
Examples
2202+
See Also
21892203
--------
2204+
pandas.DataFrame.rolling.aggregate
21902205
2206+
Notes
2207+
-----
2208+
`agg` is an alias for `aggregate`. Use the alias.
2209+
2210+
A passed user-defined-function will be passed a Series for evaluation.
2211+
2212+
Examples
2213+
--------
21912214
>>> df = pd.DataFrame(np.random.randn(10, 3), columns=['A', 'B', 'C'])
21922215
>>> df
21932216
A B C
@@ -2214,10 +2237,6 @@ def _constructor(self):
22142237
7 0.680292 0.132049 0.548693
22152238
8 0.067236 0.948257 0.163353
22162239
9 -0.286980 0.618493 -0.694496
2217-
2218-
See Also
2219-
--------
2220-
pandas.DataFrame.rolling.aggregate
22212240
""")
22222241

22232242
@Appender(_agg_doc)

0 commit comments

Comments
 (0)