@@ -5635,24 +5635,67 @@ def clip(self, lower=None, upper=None, axis=None, inplace=False,
5635
5635
5636
5636
def clip_upper (self , threshold , axis = None , inplace = False ):
5637
5637
"""
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.
5639
5643
5640
5644
Parameters
5641
5645
----------
5642
5646
threshold : float or array_like
5647
+ Maximum value allowed. All values above threshold will be
5648
+ set to this value.
5643
5649
axis : int or string axis name, optional
5644
5650
Align object with threshold along the given axis.
5645
5651
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.
5648
5653
5649
5654
See Also
5650
5655
--------
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.
5652
5658
5653
5659
Returns
5654
5660
-------
5655
5661
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
5656
5699
"""
5657
5700
return self ._clip_with_one_bound (threshold , method = self .le ,
5658
5701
axis = axis , inplace = inplace )
@@ -5661,18 +5704,21 @@ def clip_lower(self, threshold, axis=None, inplace=False):
5661
5704
"""
5662
5705
Return copy of the input with values below given value(s) truncated.
5663
5706
5707
+
5708
+
5664
5709
Parameters
5665
5710
----------
5666
5711
threshold : float or array_like
5712
+ Minimun value allowed. All values below threshold will be
5713
+ equaled to the threshold value.
5667
5714
axis : int or string axis name, optional
5668
5715
Align object with threshold along the given axis.
5669
5716
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.
5672
5718
5673
5719
See Also
5674
5720
--------
5675
- clip
5721
+ clip:
5676
5722
5677
5723
Returns
5678
5724
-------
0 commit comments