Skip to content

DOC: improved the docstring of pandas.Series.clip_upper improved #20135

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

Merged
merged 8 commits into from
Jul 8, 2018

Conversation

jalazbe
Copy link
Contributor

@jalazbe jalazbe commented Mar 10, 2018

(pandas_dev) C:\Users\Jaime\repos\MadrisSprintPandas\pandas\scripts>python validate_docstrings.py pandas.Series.clip_upper

################################################################################
##################### Docstring (pandas.Series.clip_upper) #####################
################################################################################

Return copy of the input with values above given value(s) truncated.

It truncates values above a certain threshold. Threshold can be a single
value or an array, in the latter case it performs the truncation
element-wise.

Parameters

threshold : float or array_like
Maximum value allowed. All values above threshold will be
set to this value.
axis : int or string axis name, optional
Align object with threshold along the given axis.
inplace : boolean, default False
Whether to perform the operation in place on the data.

See Also

clip : Return copy of input with values below/above thresholds truncated.
clip_lower : Return copy of input with values below given thresholds.

Returns

clipped : same type as input

Examples

s = pd.Series([1,2,3,4,5,6,7])
s
0 1
1 2
2 3
3 4
4 5
5 6
6 7
dtype: int64

s.clip_upper(4)
0 1
1 2
2 3
3 4
4 4
5 4
6 4
dtype: int64

t = [4,8,7,2,5,4,6]
t
[4, 8, 7, 2, 5, 4, 6]

s.clip_upper(t)
0 1
1 2
2 3
3 2
4 5
5 4
6 6
dtype: int64

################################################################################
################################## Validation ##################################
################################################################################

Docstring for "pandas.Series.clip_upper" correct. :)

@pep8speaks
Copy link

pep8speaks commented Mar 10, 2018

Hello @jalazbe! Thanks for updating the PR.

Cheers ! There are no PEP8 issues in this Pull Request. 🍻

Comment last updated on July 08, 2018 at 14:47 Hours UTC

Copy link
Member

@datapythonista datapythonista left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great docstring, added some comments.

It truncates values above a certain threshold. Threshold can be a
single value or an array, in the latter case it performs the
truncation
element-wise.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unnecessary break line.

It truncates values above a certain threshold. Threshold can be a
single value or an array, in the latter case it performs the
truncation
element-wise.

Parameters
----------
threshold : float or array_like
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we use array-like (with hyphen)


Parameters
----------
threshold : float or array_like
Maximum value allowed. All values above threshold will be
set to this value.
axis : int or string axis name, optional
Align object with threshold along the given axis.
inplace : boolean, default False
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we use bool instead of boolean

axis : int or string axis name, optional
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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keep the version added


Examples
--------
>>> s = pd.Series([1,2,3,4,5,6,7])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PEP-8 requires space after commas. Probably with few values it's more compact,and still shows the behavior.

6 4
dtype: int64

>>> t = [4,8,7,2,5,4,6]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same with commas

@@ -5661,18 +5705,21 @@ def clip_lower(self, threshold, axis=None, inplace=False):
"""
Return copy of the input with values below given value(s) truncated.



Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you didn't want to commit the changes to this pull request, did you?


See Also
--------
clip
clip:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing description? I think the colon requires a space in the left.

@codecov
Copy link

codecov bot commented Jul 8, 2018

Codecov Report

❗ No coverage uploaded for pull request base (master@28378fd). Click here to learn what that means.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff            @@
##             master   #20135   +/-   ##
=========================================
  Coverage          ?   91.72%           
=========================================
  Files             ?      150           
  Lines             ?    49152           
  Branches          ?        0           
=========================================
  Hits              ?    45086           
  Misses            ?     4066           
  Partials          ?        0
Flag Coverage Δ
#multiple 90.11% <100%> (?)
#single 41.84% <4.76%> (?)
Impacted Files Coverage Δ
pandas/core/generic.py 95.84% <100%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 28378fd...a77b491. Read the comment docs.

@WillAyd WillAyd force-pushed the sprint_madrid_clip_upper branch from 085f537 to a77b491 Compare July 8, 2018 14:47
@WillAyd WillAyd merged commit 20ca108 into pandas-dev:master Jul 8, 2018
@WillAyd
Copy link
Member

WillAyd commented Jul 8, 2018

Thanks @jalazbe !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants