Skip to content

Commit 51f612c

Browse files
committed
DOC: improved the docstring of pandas.Series.clip_upper improved
1 parent 4131149 commit 51f612c

File tree

1 file changed

+53
-7
lines changed

1 file changed

+53
-7
lines changed

pandas/core/generic.py

Lines changed: 53 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5635,24 +5635,67 @@ def clip(self, lower=None, upper=None, axis=None, inplace=False,
56355635

56365636
def clip_upper(self, threshold, axis=None, inplace=False):
56375637
"""
5638-
Return copy of input with values above given value(s) truncated.
5638+
Return copy of the input with values above given value(s) truncated.
5639+
5640+
It truncates values above a certain threshold. Threshold can be a single
5641+
value or an array, in the latter case it performs the truncation
5642+
element-wise.
56395643
56405644
Parameters
56415645
----------
56425646
threshold : float or array_like
5647+
Maximum value allowed. All values above threshold will be
5648+
set to this value.
56435649
axis : int or string axis name, optional
56445650
Align object with threshold along the given axis.
56455651
inplace : boolean, default False
5646-
Whether to perform the operation in place on the data
5647-
.. versionadded:: 0.21.0
5652+
Whether to perform the operation in place on the data.
56485653
56495654
See Also
56505655
--------
5651-
clip
5656+
clip : Return copy of input with values below/above thresholds truncated.
5657+
clip_lower : Return copy of input with values below given thresholds.
56525658
56535659
Returns
56545660
-------
56555661
clipped : same type as input
5662+
5663+
Examples
5664+
--------
5665+
>>> s = pd.Series([1,2,3,4,5,6,7])
5666+
>>> s
5667+
0 1
5668+
1 2
5669+
2 3
5670+
3 4
5671+
4 5
5672+
5 6
5673+
6 7
5674+
dtype: int64
5675+
5676+
>>> s.clip_upper(4)
5677+
0 1
5678+
1 2
5679+
2 3
5680+
3 4
5681+
4 4
5682+
5 4
5683+
6 4
5684+
dtype: int64
5685+
5686+
>>> t = [4,8,7,2,5,4,6]
5687+
>>> t
5688+
[4, 8, 7, 2, 5, 4, 6]
5689+
5690+
>>> s.clip_upper(t)
5691+
0 1
5692+
1 2
5693+
2 3
5694+
3 2
5695+
4 5
5696+
5 4
5697+
6 6
5698+
dtype: int64
56565699
"""
56575700
return self._clip_with_one_bound(threshold, method=self.le,
56585701
axis=axis, inplace=inplace)
@@ -5661,18 +5704,21 @@ def clip_lower(self, threshold, axis=None, inplace=False):
56615704
"""
56625705
Return copy of the input with values below given value(s) truncated.
56635706
5707+
5708+
56645709
Parameters
56655710
----------
56665711
threshold : float or array_like
5712+
Minimun value allowed. All values below threshold will be
5713+
equaled to the threshold value.
56675714
axis : int or string axis name, optional
56685715
Align object with threshold along the given axis.
56695716
inplace : boolean, default False
5670-
Whether to perform the operation in place on the data
5671-
.. versionadded:: 0.21.0
5717+
Whether to perform the operation in place on the data.
56725718
56735719
See Also
56745720
--------
5675-
clip
5721+
clip:
56765722
56775723
Returns
56785724
-------

0 commit comments

Comments
 (0)