Skip to content

Commit efec630

Browse files
jorisvandenbosschevictor
authored and
victor
committed
DOC: consolidate clip_upper and clip_lower docstrings (pandas-dev#21812)
1 parent ec8dd70 commit efec630

File tree

1 file changed

+38
-24
lines changed

1 file changed

+38
-24
lines changed

pandas/core/generic.py

+38-24
Original file line numberDiff line numberDiff line change
@@ -6547,32 +6547,46 @@ 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 the input with values above given value(s) truncated.
6550+
Trim values above a given threshold.
65516551
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.
6552+
Elements above the `threshold` will be changed to match the
6553+
`threshold` value(s). Threshold can be a single value or an array,
6554+
in the latter case it performs the truncation element-wise.
65556555
65566556
Parameters
65576557
----------
6558-
threshold : float or array-like
6558+
threshold : numeric or array-like
65596559
Maximum value allowed. All values above threshold will be set to
65606560
this value.
6561-
axis : int or string axis name, optional
6562-
Align object with threshold along the given axis.
6561+
6562+
* float : every value is compared to `threshold`.
6563+
* array-like : The shape of `threshold` should match the object
6564+
it's compared to. When `self` is a Series, `threshold` should be
6565+
the length. When `self` is a DataFrame, `threshold` should 2-D
6566+
and the same shape as `self` for ``axis=None``, or 1-D and the
6567+
same length as the axis being compared.
6568+
6569+
axis : {0 or 'index', 1 or 'columns'}, default 0
6570+
Align object with `threshold` along the given axis.
65636571
inplace : boolean, default False
65646572
Whether to perform the operation in place on the data.
65656573
65666574
.. versionadded:: 0.21.0
65676575
6568-
See Also
6569-
--------
6570-
clip : Return input copy with values below/above thresholds truncated.
6571-
clip_lower : Method to truncate values below given thresholds.
6572-
65736576
Returns
65746577
-------
6575-
clipped : same type as input
6578+
clipped
6579+
Original data with values trimmed.
6580+
6581+
See Also
6582+
--------
6583+
DataFrame.clip : General purpose method to trim DataFrame values to
6584+
given threshold(s)
6585+
DataFrame.clip_lower : Trim DataFrame values below given
6586+
threshold(s)
6587+
Series.clip : General purpose method to trim Series values to given
6588+
threshold(s)
6589+
Series.clip_lower : Trim Series values below given threshold(s)
65766590
65776591
Examples
65786592
--------
@@ -6613,7 +6627,8 @@ def clip_lower(self, threshold, axis=None, inplace=False):
66136627
Trim values below a given threshold.
66146628
66156629
Elements below the `threshold` will be changed to match the
6616-
`threshold` value(s).
6630+
`threshold` value(s). Threshold can be a single value or an array,
6631+
in the latter case it performs the truncation element-wise.
66176632
66186633
Parameters
66196634
----------
@@ -6636,20 +6651,20 @@ def clip_lower(self, threshold, axis=None, inplace=False):
66366651
66376652
.. versionadded:: 0.21.0
66386653
6654+
Returns
6655+
-------
6656+
clipped
6657+
Original data with values trimmed.
6658+
66396659
See Also
66406660
--------
6641-
DataFrame.clip : General purpose method to trim `DataFrame` values to
6661+
DataFrame.clip : General purpose method to trim DataFrame values to
66426662
given threshold(s)
6643-
DataFrame.clip_upper : Trim `DataFrame` values above given
6663+
DataFrame.clip_upper : Trim DataFrame values above given
66446664
threshold(s)
6645-
Series.clip : General purpose method to trim `Series` values to given
6665+
Series.clip : General purpose method to trim Series values to given
66466666
threshold(s)
6647-
Series.clip_upper : Trim `Series` values above given threshold(s)
6648-
6649-
Returns
6650-
-------
6651-
clipped
6652-
Original data with values trimmed.
6667+
Series.clip_upper : Trim Series values above given threshold(s)
66536668
66546669
Examples
66556670
--------
@@ -6716,7 +6731,6 @@ def clip_lower(self, threshold, axis=None, inplace=False):
67166731
0 4 5
67176732
1 4 5
67186733
2 5 6
6719-
67206734
"""
67216735
return self._clip_with_one_bound(threshold, method=self.ge,
67226736
axis=axis, inplace=inplace)

0 commit comments

Comments
 (0)