Series.clip_lower(self, threshold, axis=None, inplace=False)
[source]
Trim values below a given threshold.
Deprecated since version 0.24.0: Use clip(lower=threshold) instead.
Elements below the threshold
will be changed to match the threshold
value(s). Threshold can be a single value or an array, in the latter case it performs the truncation element-wise.
Parameters: |
|
---|---|
Returns: |
|
See also
Series.clip
DataFrame.clip
Series single threshold clipping:
>>> s = pd.Series([5, 6, 7, 8, 9]) >>> s.clip(lower=8) 0 8 1 8 2 8 3 8 4 9 dtype: int64
Series clipping element-wise using an array of thresholds. threshold
should be the same length as the Series.
>>> elemwise_thresholds = [4, 8, 7, 2, 5] >>> s.clip(lower=elemwise_thresholds) 0 5 1 8 2 7 3 8 4 9 dtype: int64
DataFrames can be compared to a scalar.
>>> df = pd.DataFrame({"A": [1, 3, 5], "B": [2, 4, 6]}) >>> df A B 0 1 2 1 3 4 2 5 6
>>> df.clip(lower=3) A B 0 3 3 1 3 4 2 5 6
Or to an array of values. By default, threshold
should be the same shape as the DataFrame.
>>> df.clip(lower=np.array([[3, 4], [2, 2], [6, 2]])) A B 0 3 4 1 3 4 2 6 6
Control how threshold
is broadcast with axis
. In this case threshold
should be the same length as the axis specified by axis
.
>>> df.clip(lower=[3, 3, 5], axis='index') A B 0 3 3 1 3 4 2 5 6
>>> df.clip(lower=[4, 5], axis='columns') A B 0 4 5 1 4 5 2 5 6
© 2008–2012, AQR Capital Management, LLC, Lambda Foundry, Inc. and PyData Development Team
Licensed under the 3-clause BSD License.
https://pandas.pydata.org/pandas-docs/version/0.25.0/reference/api/pandas.Series.clip_lower.html