@@ -4545,16 +4545,16 @@ def pipe(self, func, *args, **kwargs):
4545
4545
4546
4546
Parameters
4547
4547
----------
4548
- func : function, string , list of functions and/or strings or dict
4548
+ func : function, str , list or dict
4549
4549
Function to use for aggregating the data. If a function, must either
4550
4550
work when passed a %(klass)s or when passed to %(klass)s.apply.
4551
4551
4552
4552
Accepted combinations are:
4553
4553
4554
- - string function name
4555
4554
- function
4556
- - list of functions and/or function names
4557
- - dict of axis labels -> functions, function names or list of such
4555
+ - string function name
4556
+ - list of functions and/or function names, e.g. ``[np.sum, 'mean']``
4557
+ - dict of axis labels -> functions, function names or list of such.
4558
4558
%(axis)s
4559
4559
*args
4560
4560
Positional arguments to pass to `func`.
@@ -4563,7 +4563,11 @@ def pipe(self, func, *args, **kwargs):
4563
4563
4564
4564
Returns
4565
4565
-------
4566
- pandas.%(klass)s
4566
+ DataFrame, Series or scalar
4567
+ if DataFrame.agg is called with a single function, returns a Series
4568
+ if DataFrame.agg is called with several functions, returns a DataFrame
4569
+ if Series.agg is called with single function, returns a scalar
4570
+ if Series.agg is called with several functions, returns a Series
4567
4571
4568
4572
Notes
4569
4573
-----
@@ -4580,15 +4584,15 @@ def pipe(self, func, *args, **kwargs):
4580
4584
4581
4585
Parameters
4582
4586
----------
4583
- func : function, string , list of functions and/or strings or dict
4587
+ func : function, str , list or dict
4584
4588
Function to use for transforming the data. If a function, must either
4585
4589
work when passed a %(klass)s or when passed to %(klass)s.apply.
4586
4590
4587
4591
Accepted combinations are:
4588
4592
4589
- - string function name
4590
4593
- function
4591
- - list of functions and/or function names
4594
+ - string function name
4595
+ - list of functions and/or function names, e.g. ``[np.exp. 'sqrt']``
4592
4596
- dict of axis labels -> functions, function names or list of such.
4593
4597
%(axis)s
4594
4598
*args
@@ -4598,31 +4602,41 @@ def pipe(self, func, *args, **kwargs):
4598
4602
4599
4603
Returns
4600
4604
-------
4601
- pandas. %(klass)s
4605
+ %(klass)s
4602
4606
A %(klass)s that must have the same length as self.
4603
4607
4604
4608
Raises
4605
4609
------
4606
- ValueError : if the returned %(klass)s has a different length than self.
4610
+ ValueError : If the returned %(klass)s has a different length than self.
4607
4611
4608
4612
See Also
4609
4613
--------
4610
- pandas. %(klass)s.agg : only perform aggregating type operations
4611
- pandas. %(klass)s.apply : Invoke function on a Series
4614
+ %(klass)s.agg : Only perform aggregating type operations.
4615
+ %(klass)s.apply : Invoke function on a %(klass)s.
4612
4616
4613
4617
Examples
4614
4618
--------
4615
4619
>>> df = pd.DataFrame({'A': range(3), 'B': range(1, 4)})
4620
+ >>> df
4621
+ A B
4622
+ 0 0 1
4623
+ 1 1 2
4624
+ 2 2 3
4616
4625
>>> df.transform(lambda x: x + 1)
4617
4626
A B
4618
4627
0 1 2
4619
4628
1 2 3
4620
4629
2 3 4
4621
4630
4622
- Even though the resulting %(klass)s must have the length as the input
4623
- %(klass)s, it is possible to provide several input functions:
4631
+ Even though the resulting %(klass)s must have the same length as the
4632
+ input %(klass)s, it is possible to provide several input functions:
4624
4633
4625
4634
>>> s = pd.Series(range(3))
4635
+ >>> s
4636
+ 0 0
4637
+ 1 1
4638
+ 2 2
4639
+ dtype: int64
4626
4640
>>> s.transform([np.sqrt, np.exp])
4627
4641
sqrt exp
4628
4642
0 0.000000 1.000000
0 commit comments