-
-
Notifications
You must be signed in to change notification settings - Fork 18.6k
DOC: Improved the docstring of pandas.Series.clip #20178
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: Improved the docstring of pandas.Series.clip #20178
Conversation
ReubenMarkham
commented
Mar 10, 2018
Hello @ReubenMarkham! Thanks for updating the PR. Cheers ! There are no PEP8 issues in this Pull Request. 🍻 Comment last updated on March 10, 2018 at 16:27 Hours UTC |
pandas/core/generic.py
Outdated
1 -3 -7 | ||
2 0 6 | ||
3 -1 8 | ||
4 5 -5 |
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.
alignment of the printed output seems strange. Should align right for each individual column
pandas/core/generic.py
Outdated
|
||
Returns | ||
------- | ||
clipped : Series | ||
|
||
Examples | ||
-------- | ||
>>> data = {'0': [9, -3, 0, -1, 5], '1': [-2, -7, 6, 8, -5]} |
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.
cfr. docstring guide, use actual names for the column names instead of 0
, 1
pandas/core/generic.py
Outdated
1 -3 -4 | ||
2 0 6 | ||
3 -1 6 | ||
4 5 -4 |
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.
cfr. comment on alignment
pandas/core/generic.py
Outdated
@@ -5548,53 +5548,74 @@ def clip(self, lower=None, upper=None, axis=None, inplace=False, | |||
""" | |||
Trim values at input threshold(s). | |||
|
|||
Truncates values below and above specified thresholds. |
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.
Truncates feels like you throw away the values outside the specified range. I would make it more descriptive by actually saying that values outside the boundaries are reset to the boundary values.
pandas/core/generic.py
Outdated
See Also | ||
-------- | ||
clip_lower : Clips values below specified threshold(s). | ||
clip_upper : Clips values above specified threshold(s). |
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.
Clips -> Clip
pandas/core/generic.py
Outdated
.. versionadded:: 0.21.0. | ||
args : iterable, optional | ||
Arguments to pass to the function. | ||
kwargs : mapping, optional |
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.
kwargs -> **kwargs
pandas/core/generic.py
Outdated
axis : int or string axis name, optional | ||
Align object with lower and upper along the given axis. | ||
inplace : boolean, default False | ||
Whether to perform the operation in place on the data | ||
.. versionadded:: 0.21.0 | ||
.. versionadded:: 0.21.0. | ||
args : iterable, optional |
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.
args -> *args
pandas/core/generic.py
Outdated
args : iterable, optional | ||
Arguments to pass to the function. | ||
kwargs : mapping, optional | ||
Keyworded arguments to pass to the function. |
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.
See discussion on https://github.com/pandas-dev/pandas/pull/19985/files#diff-248241e14f081931cc805f9d0e137a5fR709
maybe change to:
*args, **kwargs
Additional keywords have no effect but might be accepted
for compatibility with numpy.
pandas/core/generic.py
Outdated
See Also | ||
-------- | ||
clip_lower : Clips values below specified threshold(s). | ||
clip_upper : Clips values above specified threshold(s). | ||
|
||
Returns | ||
------- | ||
clipped : Series |
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.
Returns
----------
`pandas.Series`
Series with the values outside the clip boundaries replaced
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.
Good!
@ReubenMarkham why this branch is closed instead of merged? |
@stijnvanhoey Hi!, you can find the PR related to this method here: #20256 Reuben asked me to continue his job and all your suggestions should be already included in the new PR. |
Great! Would have been a pity to not include the work of Reuben. Nice work! |