Skip to content

Commit 20ca108

Browse files
jalazbeWillAyd
authored andcommitted
DOC: improved the docstring of pandas.Series.clip_upper improved (#20135)
1 parent 28378fd commit 20ca108

File tree

1 file changed

+42
-4
lines changed

1 file changed

+42
-4
lines changed

pandas/core/generic.py

+42-4
Original file line numberDiff line numberDiff line change
@@ -6547,25 +6547,63 @@ def clip(self, lower=None, upper=None, axis=None, inplace=False,
65476547

65486548
def clip_upper(self, threshold, axis=None, inplace=False):
65496549
"""
6550-
Return copy of input with values above given value(s) truncated.
6550+
Return copy of the input with values above given value(s) truncated.
6551+
6552+
It truncates values above a certain threshold. Threshold can be a
6553+
single value or an array, in the latter case it performs the truncation
6554+
element-wise.
65516555
65526556
Parameters
65536557
----------
6554-
threshold : float or array_like
6558+
threshold : float or array-like
6559+
Maximum value allowed. All values above threshold will be set to
6560+
this value.
65556561
axis : int or string axis name, optional
65566562
Align object with threshold along the given axis.
65576563
inplace : boolean, default False
6558-
Whether to perform the operation in place on the data
6564+
Whether to perform the operation in place on the data.
65596565
65606566
.. versionadded:: 0.21.0
65616567
65626568
See Also
65636569
--------
6564-
clip
6570+
clip : Return input copy with values below/above thresholds truncated.
6571+
clip_lower : Method to truncate values below given thresholds.
65656572
65666573
Returns
65676574
-------
65686575
clipped : same type as input
6576+
6577+
Examples
6578+
--------
6579+
>>> s = pd.Series([1, 2, 3, 4, 5])
6580+
>>> s
6581+
0 1
6582+
1 2
6583+
2 3
6584+
3 4
6585+
4 5
6586+
dtype: int64
6587+
6588+
>>> s.clip_upper(3)
6589+
0 1
6590+
1 2
6591+
2 3
6592+
3 3
6593+
4 3
6594+
dtype: int64
6595+
6596+
>>> t = [5, 4, 3, 2, 1]
6597+
>>> t
6598+
[5, 4, 3, 2, 1]
6599+
6600+
>>> s.clip_upper(t)
6601+
0 1
6602+
1 2
6603+
2 3
6604+
3 2
6605+
4 1
6606+
dtype: int64
65696607
"""
65706608
return self._clip_with_one_bound(threshold, method=self.le,
65716609
axis=axis, inplace=inplace)

0 commit comments

Comments
 (0)