-
-
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
Conversation
DOC: update the GroupBy.apply see also to include description
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.
Thanks for the docstring!
Can you change the occurences of ``func``
to `func`
? (we use single backtick quotes for parameter names)
pandas/core/groupby.py
Outdated
args, kwargs : tuple and dict | ||
Optional positional and keyword arguments to pass to ``func`` | ||
callable may take positional and keyword arguments. | ||
args : tuple |
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')
pandas/core/groupby.py
Outdated
callable may take positional and keyword arguments. | ||
args : tuple | ||
Optional positional and keyword arguments to pass to ``func``. | ||
kwargs : dict |
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.
Here the same **kwargs
(and without dict
)
pandas/core/groupby.py
Outdated
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 comment
The 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
Codecov Report
@@ Coverage Diff @@
## master #20098 +/- ##
==========================================
- Coverage 91.99% 91.73% -0.27%
==========================================
Files 167 150 -17
Lines 50578 49168 -1410
==========================================
- Hits 46530 45102 -1428
- Misses 4048 4066 +18
Continue to review full report at Codecov.
|
pandas/core/groupby.py
Outdated
@@ -118,12 +120,12 @@ | |||
Examples | |||
-------- | |||
{examples} | |||
|
|||
See also | |||
-------- |
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 reference Series/DataFrame.apply as well
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.
Could you add these to the See Also?
pandas/core/groupby.py
Outdated
@@ -216,17 +216,17 @@ | |||
---------- | |||
func : callable or tuple of (callable, string) | |||
Function to apply to this %(klass)s object or, alternatively, | |||
a ``(callable, data_keyword)`` tuple where ``data_keyword`` is a | |||
string indicating the keyword of ``callable`` that expects the | |||
a `(callable, data_keyword)` tuple where `data_keyword` is a |
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.
I think this tuple should be double-backticks, since it's a code snippet.
pandas/core/groupby.py
Outdated
@@ -394,7 +394,7 @@ class Grouper(object): | |||
Examples | |||
-------- | |||
|
|||
Syntactic sugar for ``df.groupby('A')`` | |||
Syntactic sugar for `df.groupby('A')` |
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.
double backticks
pandas/core/groupby.py
Outdated
@@ -1641,7 +1641,7 @@ def nth(self, n, dropna=None): | |||
1 NaN | |||
2 NaN | |||
|
|||
Specifying ``as_index=False`` in ``groupby`` keeps the original index. | |||
Specifying `as_index=False` in `groupby` keeps the original index. |
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.
double backtick for as_index=False
pandas/core/groupby.py
Outdated
@@ -2067,7 +2067,7 @@ def head(self, n=5): | |||
""" | |||
Returns first n rows of each group. | |||
|
|||
Essentially equivalent to ``.apply(lambda x: x.head(n))``, | |||
Essentially equivalent to `.apply(lambda x: x.head(n))`, |
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.
double backticks
pandas/core/groupby.py
Outdated
@@ -2094,7 +2094,7 @@ def tail(self, n=5): | |||
""" | |||
Returns last n rows of each group | |||
|
|||
Essentially equivalent to ``.apply(lambda x: x.tail(n))``, | |||
Essentially equivalent to `.apply(lambda x: x.tail(n))`, |
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.
double backtics
pandas/core/groupby.py
Outdated
@@ -118,12 +120,12 @@ | |||
Examples | |||
-------- | |||
{examples} | |||
|
|||
See also | |||
-------- |
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.
Could you add these to the See Also?
pandas/core/groupby.py
Outdated
args, kwargs : tuple and dict | ||
Optional positional and keyword arguments to pass to ``func`` | ||
callable may take positional and keyword arguments. | ||
*args : Optional positional and keyword arguments to pass to `func`. |
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.
This should be formatted as
*args
Additional positional arguments are passed through to `func`.
**kwargs
Additional keyword arguments are passed through to `func`.
[ci skip]
* Undo some single backticking * PEP8 on examples * Reword [ci skip]
can you rebase this |
Thanks @ajdyka ! |
Checklist for the pandas documentation sprint (ignore this if you are doing
an unrelated PR):
scripts/validate_docstrings.py <your-function-or-method>
git diff upstream/master -u -- "*.py" | flake8 --diff
python doc/make.py --single <your-function-or-method>
Please include the output of the validation script below between the "```" ticks: