-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
DOC: update the GroupBy.apply docstring #20098
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
Changes from 6 commits
5bffa50
7c51bb5
304e943
a35eef1
f9a253f
4ec814a
d1faa3d
9ab975a
e88d7f1
ac44f39
cf3b3e9
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 |
---|---|---|
|
@@ -99,9 +99,11 @@ | |
func : function | ||
A callable that takes a {input} as its first argument, and | ||
returns a dataframe, a series or a scalar. In addition the | ||
callable may take positional and keyword arguments | ||
args, kwargs : tuple and dict | ||
Optional positional and keyword arguments to pass to ``func`` | ||
callable may take positional and keyword arguments. | ||
args : tuple | ||
Optional positional and keyword arguments to pass to ``func``. | ||
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 are only the positional ones, and below the keyword ones. I think it would also be a good idea to add an example of this in the Examples section |
||
kwargs : dict | ||
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. Here the same |
||
Optional positional and keyword arguments to pass to ``func``. | ||
|
||
Returns | ||
------- | ||
|
@@ -118,12 +120,12 @@ | |
Examples | ||
-------- | ||
{examples} | ||
|
||
See also | ||
-------- | ||
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. can you reference Series/DataFrame.apply as well 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. Could you add these to the See Also? |
||
pipe : Apply function to the full GroupBy object instead of to each | ||
group. | ||
aggregate, transform | ||
aggregate : Apply aggregate function to the GroupBy object. | ||
transform : Apply function column-by-column to the GroupBy object. | ||
""", | ||
dataframe_examples=""" | ||
>>> df = pd.DataFrame({'A': 'a a b'.split(), 'B': [1,2,3], 'C': [4,6, 5]}) | ||
|
@@ -136,7 +138,7 @@ | |
its argument and returns a dataframe. ``apply`` combines the result for | ||
each group together into a new dataframe: | ||
|
||
>>> g.apply(lambda x: x / x.sum()) | ||
>>> g[['B','C']].apply(lambda x: x / x.sum()) | ||
B C | ||
0 0.333333 0.4 | ||
1 0.666667 0.6 | ||
|
@@ -146,7 +148,7 @@ | |
its argument and returns a series. ``apply`` combines the result for | ||
each group together into a new dataframe: | ||
|
||
>>> g.apply(lambda x: x.max() - x.min()) | ||
>>> g[['B','C']].apply(lambda x: x.max() - x.min()) | ||
B C | ||
A | ||
a 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.
Can you make this
*args
? (and you can leave out the 'tuple')