-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
DOC: update the pandas.DataFrame.clip_lower docstring #20289
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 5 commits
d1bb286
22a256f
5312dd0
ba4c362
13c9d82
4e2e0d7
e48d49b
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 |
---|---|---|
|
@@ -5716,24 +5716,81 @@ def clip_upper(self, threshold, axis=None, inplace=False): | |
|
||
def clip_lower(self, threshold, axis=None, inplace=False): | ||
""" | ||
Return copy of the input with values below given value(s) truncated. | ||
Trim the caller's values below a given `threshold`. | ||
|
||
Elements below the `threshold` will be changed to match the | ||
`threshold` value(s). | ||
|
||
Parameters | ||
---------- | ||
threshold : float or array_like | ||
axis : int or string axis name, optional | ||
threshold : float or array-like | ||
Lower value(s) to which the input value(s) will be trimmed. | ||
axis : {0 or 'index', 1 or 'columns', None}, default None | ||
Align object with threshold along the given axis. | ||
inplace : boolean, default False | ||
Whether to perform the operation in place on the data | ||
.. versionadded:: 0.21.0 | ||
Whether to perform the operation in place on the data. | ||
|
||
.. versionadded:: 0.21.0 | ||
|
||
See Also | ||
-------- | ||
clip | ||
DataFrame.clip : General purpose method to trim `DataFrame` values to | ||
given threshold(s) | ||
DataFrame.clip_upper : Trim `DataFrame` values above given | ||
threshold(s) | ||
Series.clip : General purpose method to trim `Series` values to given | ||
threshold(s) | ||
Series.clip_upper : Trim `Series` values above given threshold(s) | ||
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. Ideally, for
So, the same in 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. Only caveat here is that the user is working on a doc that is shared by I advised just removing it to not get hung up on it for now, the other option would be to explicitly list both 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. Sorry, I was waiting for a little clarification, since I'm not sure how to proceed. I can go either way, but I haven't seen a conclusive definition. Was a decision made on how to proceed with these? 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. If I'm not wrong, in another ticket the final implementation just listed everything. As @WillAyd says in some cases the same method being documented will be self-referenced, but it's not a big issue. |
||
|
||
Returns | ||
------- | ||
clipped : same type as input | ||
type of caller | ||
Original data with values trimmed. | ||
|
||
Examples | ||
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. Nice job here - I think the examples are very clear |
||
-------- | ||
>>> df = pd.DataFrame({'a': [-1, -2, -100], | ||
... 'b': [1, 2, 100]}, | ||
... index = ['foo', 'bar', 'foobar']) | ||
|
||
>>> df | ||
a b | ||
foo -1 1 | ||
bar -2 2 | ||
foobar -100 100 | ||
|
||
Clip to a scalar value | ||
|
||
>>> df.clip_lower(0) | ||
a b | ||
foo 0 1 | ||
bar 0 2 | ||
foobar 0 100 | ||
|
||
Clip to an array along the index axis | ||
|
||
>>> df.clip_lower([0, 5, 10], axis=0) | ||
a b | ||
foo 0 1 | ||
bar 5 5 | ||
foobar 10 100 | ||
|
||
Clip to an array along the column axis | ||
|
||
>>> df.clip_lower([-5, 10], axis=1) | ||
a b | ||
foo -1 10 | ||
bar -2 10 | ||
foobar -5 100 | ||
|
||
Clip in place | ||
|
||
>>> df.clip_lower(0, inplace=True) | ||
>>> df | ||
a b | ||
foo 0 1 | ||
bar 0 2 | ||
foobar 0 100 | ||
""" | ||
return self._clip_with_one_bound(threshold, method=self.ge, | ||
axis=axis, inplace=inplace) | ||
|
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.
Sorry if I forgot some discussion about it, but don't we want a
See Also
section? I thinkclip
andclip_upper
should be listed.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.
Yes good spot we definitely still want this - @adatasetaday can you add back in?
I know we had some back and forth about
Series.clip_lower
being self-referential with the shared doc system. If you find that confusing just remove that one entry, but all the rest should remain