Skip to content

Commit 4bd8490

Browse files
committed
adjust for comments
1 parent 650f639 commit 4bd8490

File tree

1 file changed

+25
-37
lines changed

1 file changed

+25
-37
lines changed

pandas/core/generic.py

+25-37
Original file line numberDiff line numberDiff line change
@@ -4545,7 +4545,7 @@ def pipe(self, func, *args, **kwargs):
45454545
45464546
Parameters
45474547
----------
4548-
func : function, string, list of string/functions or dictionary
4548+
func : function, string, list of functions and/or strings or dict
45494549
Function to use for aggregating the data. If a function, must either
45504550
work when passed a %(klass)s or when passed to %(klass)s.apply.
45514551
@@ -4563,7 +4563,7 @@ def pipe(self, func, *args, **kwargs):
45634563
45644564
Returns
45654565
-------
4566-
aggregated : %(klass)s
4566+
pandas.%(klass)s
45674567
45684568
Notes
45694569
-----
@@ -4573,14 +4573,14 @@ def pipe(self, func, *args, **kwargs):
45734573
""")
45744574

45754575
_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.
45784578
45794579
.. versionadded:: 0.20.0
45804580
45814581
Parameters
45824582
----------
4583-
func : function, string, list of string/functions or dictionary
4583+
func : function, string, list of functions and/or strings or dict
45844584
Function to use for transforming the data. If a function, must either
45854585
work when passed a %(klass)s or when passed to %(klass)s.apply.
45864586
@@ -4589,7 +4589,7 @@ def pipe(self, func, *args, **kwargs):
45894589
- string function name
45904590
- function
45914591
- 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.
45934593
%(axis)s
45944594
*args
45954595
Positional arguments to pass to `func`.
@@ -4598,48 +4598,36 @@ def pipe(self, func, *args, **kwargs):
45984598
45994599
Returns
46004600
-------
4601-
transformed : %(klass)s
4601+
pandas.%(klass)s
4602+
A %(klass)s that must have the same length as self.
46024603
46034604
Raises
46044605
------
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
46064612
46074613
Examples
46084614
--------
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))
46314626
>>> s.transform([np.sqrt, np.exp])
46324627
sqrt exp
46334628
0 0.000000 1.000000
46344629
1 1.000000 2.718282
46354630
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
46434631
""")
46444632

46454633
# ----------------------------------------------------------------------

0 commit comments

Comments
 (0)