-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
DOC: Apply doc sprint #20111
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DOC: Apply doc sprint #20111
Changes from 3 commits
5a0afb2
31628ec
a5f37c7
2e4d7ee
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4818,7 +4818,8 @@ def aggregate(self, func, axis=0, *args, **kwargs): | |
|
||
def apply(self, func, axis=0, broadcast=None, raw=False, reduce=None, | ||
result_type=None, args=(), **kwds): | ||
"""Applies function along an axis of the DataFrame. | ||
""" | ||
Apply function along an axis of the DataFrame. | ||
|
||
Objects passed to functions are Series objects having index | ||
either the DataFrame's index (axis=0) or the columns (axis=1). | ||
|
@@ -4828,10 +4829,11 @@ def apply(self, func, axis=0, broadcast=None, raw=False, reduce=None, | |
Parameters | ||
---------- | ||
func : function | ||
Function to apply to each column/row | ||
Function to apply to each column/row. | ||
axis : {0 or 'index', 1 or 'columns'}, default 0 | ||
Axis along which the function is applied | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This line can have end with a period. |
||
* 0 or 'index': apply function to each column | ||
* 1 or 'columns': apply function to each row | ||
* 1 or 'columns': apply function to each row. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These bullets should both have periods, or not. I don't really have a preference, but probably best to add a period to both. |
||
broadcast : boolean, optional | ||
For aggregation functions, return object of same size with values | ||
propagated | ||
|
@@ -4844,7 +4846,7 @@ def apply(self, func, axis=0, broadcast=None, raw=False, reduce=None, | |
If False, convert each row or column into a Series. If raw=True the | ||
passed function will receive ndarray objects instead. If you are | ||
just applying a NumPy reduction function this will achieve much | ||
better performance | ||
better performance. | ||
reduce : boolean or None, default None | ||
Try to apply reduction procedures. If the DataFrame is empty, | ||
apply will use reduce to determine whether the result should be a | ||
|
@@ -4872,12 +4874,15 @@ def apply(self, func, axis=0, broadcast=None, raw=False, reduce=None, | |
of those. However if the apply function returns a Series these | ||
are expanded to columns. | ||
|
||
.. versionadded:: 0.23.0 | ||
.. versionadded:: 0.23.0. | ||
|
||
args : tuple | ||
Positional arguments to pass to function in addition to the | ||
array/series | ||
Additional keyword arguments will be passed as keywords to the function | ||
array/series. | ||
|
||
kwds : dictionary | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @jorisvandenbossche remind me, what's the policy here? Just There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Though probably just There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
Additional keyword arguments will be passed as keywords to | ||
the function. | ||
|
||
Notes | ||
----- | ||
|
@@ -4941,6 +4946,7 @@ def apply(self, func, axis=0, broadcast=None, raw=False, reduce=None, | |
3 [1, 2] | ||
4 [1, 2] | ||
5 [1, 2] | ||
dtype: object | ||
|
||
Passing result_type='expand' will expand list-like results | ||
to columns of a Dataframe | ||
|
@@ -4958,7 +4964,7 @@ def apply(self, func, axis=0, broadcast=None, raw=False, reduce=None, | |
``result_type='expand'``. The resulting column names | ||
will be the Series index. | ||
|
||
>>> df.apply(lambda x: Series([1, 2], index=['foo', 'bar']), axis=1) | ||
>>> df.apply(lambda x: pd.Series([1, 2], index=['foo', 'bar']), axis=1) | ||
foo bar | ||
0 1 2 | ||
1 1 2 | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe "Apply a function along an axis of the DataFrame." (add "a" before "function").