Skip to content

Commit 819b267

Browse files
committed
various updates
1 parent a149892 commit 819b267

File tree

5 files changed

+71
-70
lines changed

5 files changed

+71
-70
lines changed

pandas/core/frame.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -4228,6 +4228,9 @@ def _gotitem(self, key, ndim, subset=None):
42284228
--------
42294229
pandas.DataFrame.apply
42304230
pandas.DataFrame.transform
4231+
pandas.DataFrame.groupby.aggregate
4232+
pandas.DataFrame.resample.aggregate
4233+
pandas.DataFrame.rolling.aggregate
42314234
42324235
""")
42334236

@@ -4306,7 +4309,7 @@ def apply(self, func, axis=0, broadcast=False, raw=False, reduce=None,
43064309
See also
43074310
--------
43084311
DataFrame.applymap: For elementwise operations
4309-
DataFrame.agg: only perform aggregating type operations
4312+
DataFrame.aggregate: only perform aggregating type operations
43104313
DataFrame.transform: only perform transformating type operations
43114314
43124315
Returns

pandas/core/generic.py

+7
Original file line numberDiff line numberDiff line change
@@ -2879,6 +2879,8 @@ def pipe(self, func, *args, **kwargs):
28792879
(e.g., np.mean(arr_2d, axis=0)) as opposed to
28802880
mimicking the default Numpy behavior (e.g., np.mean(arr_2d)).
28812881
2882+
agg is an alias for aggregate. Use it.
2883+
28822884
Returns
28832885
-------
28842886
aggregated : %(klass)s
@@ -2925,6 +2927,11 @@ def pipe(self, func, *args, **kwargs):
29252927
2000-01-09 -0.540524 -1.012676 -0.828968
29262928
2000-01-10 -1.366388 -0.614710 0.005378
29272929
2930+
See also
2931+
--------
2932+
pandas.%(klass)s.aggregate
2933+
pandas.%(klass)s.apply
2934+
29282935
""")
29292936

29302937
# ----------------------------------------------------------------------

pandas/core/groupby.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -2780,9 +2780,9 @@ def _selection_name(self):
27802780
27812781
See also
27822782
--------
2783-
pandas.Series.apply
2783+
pandas.Series.groupby.apply
2784+
pandas.Series.groupby.transform
27842785
pandas.Series.aggregate
2785-
pandas.Series.transform
27862786
27872787
""")
27882788

@@ -3947,9 +3947,9 @@ class DataFrameGroupBy(NDFrameGroupBy):
39473947
39483948
See also
39493949
--------
3950-
pandas.DataFrame.apply
3950+
pandas.DataFrame.groupby.apply
3951+
pandas.DataFrame.groupby.transform
39513952
pandas.DataFrame.aggregate
3952-
pandas.DataFrame.transform
39533953
39543954
""")
39553955

pandas/core/resample.py

+50-59
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import numpy as np
33
import warnings
44
import copy
5+
from textwrap import dedent
56

67
import pandas as pd
78
from pandas.core.base import AbstractMethodError, GroupByMixin
@@ -254,66 +255,56 @@ def plot(self, *args, **kwargs):
254255
# have the warnings shown here and just have this work
255256
return self._deprecated('plot').plot(*args, **kwargs)
256257

258+
_agg_doc = dedent("""
259+
260+
Examples
261+
--------
262+
>>> s = Series([1,2,3,4,5],
263+
index=pd.date_range('20130101',
264+
periods=5,freq='s'))
265+
2013-01-01 00:00:00 1
266+
2013-01-01 00:00:01 2
267+
2013-01-01 00:00:02 3
268+
2013-01-01 00:00:03 4
269+
2013-01-01 00:00:04 5
270+
Freq: S, dtype: int64
271+
272+
>>> r = s.resample('2s')
273+
DatetimeIndexResampler [freq=<2 * Seconds>, axis=0, closed=left,
274+
label=left, convention=start, base=0]
275+
276+
>>> r.agg(np.sum)
277+
2013-01-01 00:00:00 3
278+
2013-01-01 00:00:02 7
279+
2013-01-01 00:00:04 5
280+
Freq: 2S, dtype: int64
281+
282+
>>> r.agg(['sum','mean','max'])
283+
sum mean max
284+
2013-01-01 00:00:00 3 1.5 2
285+
2013-01-01 00:00:02 7 3.5 4
286+
2013-01-01 00:00:04 5 5.0 5
287+
288+
>>> r.agg({'result' : lambda x: x.mean() / x.std(),
289+
'total' : np.sum})
290+
total result
291+
2013-01-01 00:00:00 3 2.121320
292+
2013-01-01 00:00:02 7 4.949747
293+
2013-01-01 00:00:04 5 NaN
294+
295+
See also
296+
--------
297+
pandas.DataFrame.groupby.aggregate
298+
pandas.DataFrame.resample.transform
299+
pandas.DataFrame.aggregate
300+
301+
""")
302+
303+
@Appender(_agg_doc)
304+
@Appender(_shared_docs['aggregate'] % dict(
305+
klass='DataFrame',
306+
versionadded=''))
257307
def aggregate(self, arg, *args, **kwargs):
258-
"""
259-
Apply aggregation function or functions to resampled groups, yielding
260-
most likely Series but in some cases DataFrame depending on the output
261-
of the aggregation function
262-
263-
Parameters
264-
----------
265-
func_or_funcs : function or list / dict of functions
266-
List/dict of functions will produce DataFrame with column names
267-
determined by the function names themselves (list) or the keys in
268-
the dict
269-
270-
Notes
271-
-----
272-
agg is an alias for aggregate. Use it.
273-
274-
Examples
275-
--------
276-
>>> s = Series([1,2,3,4,5],
277-
index=pd.date_range('20130101',
278-
periods=5,freq='s'))
279-
2013-01-01 00:00:00 1
280-
2013-01-01 00:00:01 2
281-
2013-01-01 00:00:02 3
282-
2013-01-01 00:00:03 4
283-
2013-01-01 00:00:04 5
284-
Freq: S, dtype: int64
285-
286-
>>> r = s.resample('2s')
287-
DatetimeIndexResampler [freq=<2 * Seconds>, axis=0, closed=left,
288-
label=left, convention=start, base=0]
289-
290-
>>> r.agg(np.sum)
291-
2013-01-01 00:00:00 3
292-
2013-01-01 00:00:02 7
293-
2013-01-01 00:00:04 5
294-
Freq: 2S, dtype: int64
295-
296-
>>> r.agg(['sum','mean','max'])
297-
sum mean max
298-
2013-01-01 00:00:00 3 1.5 2
299-
2013-01-01 00:00:02 7 3.5 4
300-
2013-01-01 00:00:04 5 5.0 5
301-
302-
>>> r.agg({'result' : lambda x: x.mean() / x.std(),
303-
'total' : np.sum})
304-
total result
305-
2013-01-01 00:00:00 3 2.121320
306-
2013-01-01 00:00:02 7 4.949747
307-
2013-01-01 00:00:04 5 NaN
308-
309-
See also
310-
--------
311-
transform
312-
313-
Returns
314-
-------
315-
Series or DataFrame
316-
"""
317308

318309
self._set_binner()
319310
result, how = self._aggregate(arg, *args, **kwargs)

pandas/core/window.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -645,8 +645,8 @@ def f(arg, *args, **kwargs):
645645
646646
See also
647647
--------
648-
pandas.Series.rolling
649-
pandas.DataFrame.rolling
648+
pandas.DataFrame.rolling.aggregate
649+
pandas.DataFrame.aggregate
650650
651651
""")
652652

@@ -1414,8 +1414,9 @@ def _get_window(self, other=None):
14141414
14151415
See also
14161416
--------
1417-
pandas.Series.expanding
1418-
pandas.DataFrame.expanding
1417+
pandas.DataFrame.expanding.aggregate
1418+
pandas.DataFrame.rolling.aggregate
1419+
pandas.DataFrame.aggregate
14191420
14201421
""")
14211422

@@ -1699,8 +1700,7 @@ def _constructor(self):
16991700
17001701
See also
17011702
--------
1702-
pandas.Series.ewm
1703-
pandas.DataFrame.ewm
1703+
pandas.DataFrame.rolling.aggregate
17041704
17051705
""")
17061706

0 commit comments

Comments
 (0)