@@ -4545,7 +4545,7 @@ def pipe(self, func, *args, **kwargs):
4545
4545
4546
4546
Parameters
4547
4547
----------
4548
- func : function, string, list of string/ functions or dictionary
4548
+ func : function, string, list of functions and/ or strings 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
@@ -4563,7 +4563,7 @@ def pipe(self, func, *args, **kwargs):
4563
4563
4564
4564
Returns
4565
4565
-------
4566
- aggregated : %(klass)s
4566
+ pandas. %(klass)s
4567
4567
4568
4568
Notes
4569
4569
-----
@@ -4573,14 +4573,14 @@ def pipe(self, func, *args, **kwargs):
4573
4573
""" )
4574
4574
4575
4575
_shared_docs ['transform' ] = ("""
4576
- Call function producing a like-indexed %(klass)s
4577
- and return a %(klass)s with the transformed values
4576
+ Call ``func`` on self producing a %(klass)s with transformed values
4577
+ and that has the same axis length as self.
4578
4578
4579
4579
.. versionadded:: 0.20.0
4580
4580
4581
4581
Parameters
4582
4582
----------
4583
- func : function, string, list of string/ functions or dictionary
4583
+ func : function, string, list of functions and/ or strings or dict
4584
4584
Function to use for transforming the data. If a function, must either
4585
4585
work when passed a %(klass)s or when passed to %(klass)s.apply.
4586
4586
@@ -4589,7 +4589,7 @@ def pipe(self, func, *args, **kwargs):
4589
4589
- string function name
4590
4590
- function
4591
4591
- list of functions and/or function names
4592
- - dict of axis labels -> functions, function names or list of such
4592
+ - dict of axis labels -> functions, function names or list of such.
4593
4593
%(axis)s
4594
4594
*args
4595
4595
Positional arguments to pass to `func`.
@@ -4598,48 +4598,36 @@ def pipe(self, func, *args, **kwargs):
4598
4598
4599
4599
Returns
4600
4600
-------
4601
- transformed : %(klass)s
4601
+ pandas.%(klass)s
4602
+ A %(klass)s that must have the same length as self.
4602
4603
4603
4604
Raises
4604
4605
------
4605
- ValueError: if the returned %(klass)s has a different length than self.
4606
+ ValueError : if the returned %(klass)s has a different length than self.
4607
+
4608
+ See Also
4609
+ --------
4610
+ pandas.%(klass)s.agg : only perform aggregating type operations
4611
+ pandas.%(klass)s.apply : Invoke function on a Series
4606
4612
4607
4613
Examples
4608
4614
--------
4609
- >>> df = pd.DataFrame({'A': range(10), 'B': range(10, 0, -1)},
4610
- ... index=pd.date_range('1/1/2000', periods=10))
4611
- >>> df.iloc[3:7] = np.nan
4612
-
4613
- >>> df.transform(lambda x: (x - x.mean()) / x.std())
4614
- A B
4615
- 2000-01-01 -1.143001 1.143001
4616
- 2000-01-02 -0.889001 0.889001
4617
- 2000-01-03 -0.635001 0.635001
4618
- 2000-01-04 NaN NaN
4619
- 2000-01-05 NaN NaN
4620
- 2000-01-06 NaN NaN
4621
- 2000-01-07 NaN NaN
4622
- 2000-01-08 0.635001 -0.635001
4623
- 2000-01-09 0.889001 -0.889001
4624
- 2000-01-10 1.143001 -1.143001
4625
-
4626
- It is only required for the axis specified in the ``axis`` parameter
4627
- to have the same length for output and for self. The other axis may have a
4628
- different length:
4629
-
4630
- >>> s = pd.Series(range(5))
4615
+ >>> df = pd.DataFrame({'A': range(3), 'B': range(1, 4)})
4616
+ >>> df.transform(lambda x: x + 1)
4617
+ A B
4618
+ 0 1 2
4619
+ 1 2 3
4620
+ 2 3 4
4621
+
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:
4624
+
4625
+ >>> s = pd.Series(range(3))
4631
4626
>>> s.transform([np.sqrt, np.exp])
4632
4627
sqrt exp
4633
4628
0 0.000000 1.000000
4634
4629
1 1.000000 2.718282
4635
4630
2 1.414214 7.389056
4636
- 3 1.732051 20.085537
4637
- 4 2.000000 54.598150
4638
-
4639
- See also
4640
- --------
4641
- pandas.%(klass)s.aggregate
4642
- pandas.%(klass)s.apply
4643
4631
""" )
4644
4632
4645
4633
# ----------------------------------------------------------------------
0 commit comments