@@ -6547,25 +6547,63 @@ def clip(self, lower=None, upper=None, axis=None, inplace=False,
6547
6547
6548
6548
def clip_upper (self , threshold , axis = None , inplace = False ):
6549
6549
"""
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.
6551
6555
6552
6556
Parameters
6553
6557
----------
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.
6555
6561
axis : int or string axis name, optional
6556
6562
Align object with threshold along the given axis.
6557
6563
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.
6559
6565
6560
6566
.. versionadded:: 0.21.0
6561
6567
6562
6568
See Also
6563
6569
--------
6564
- clip
6570
+ clip : Return input copy with values below/above thresholds truncated.
6571
+ clip_lower : Method to truncate values below given thresholds.
6565
6572
6566
6573
Returns
6567
6574
-------
6568
6575
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
6569
6607
"""
6570
6608
return self ._clip_with_one_bound (threshold , method = self .le ,
6571
6609
axis = axis , inplace = inplace )
0 commit comments