Loading...

verticapy.vDataColumn.clip#

vDataColumn.clip(lower: bool | float | str | timedelta | datetime | None = None, upper: bool | float | str | timedelta | datetime | None = None) vDataFrame#

Clips the vDataColumn by transforming the values less than the lower bound to the lower bound value and the values higher than the upper bound to the upper bound value.

Parameters#

lower: PythonScalar, optional

Lower bound.

upper: PythonScalar, optional

Upper bound.

Returns#

vDataFrame

self._parent

Examples#

We import verticapy:

import verticapy as vp

Hint

By assigning an alias to verticapy, we mitigate the risk of code collisions with other libraries. This precaution is necessary because verticapy uses commonly known function names like “average” and “median”, which can potentially lead to naming conflicts. The use of an alias ensures that the functions from verticapy are used as intended without interfering with functions from other libraries.

For this example, we will use a dummy time-series data:

vdf = vp.vDataFrame({"vals": [-20, -10, 0, -20, 10, 20, 120]})
123
vals
Integer
100%
1-20
2-10
30
4-20
510
620
7120

Note

VerticaPy offers a wide range of sample datasets that are ideal for training and testing purposes. You can explore the full list of available datasets in the Datasets, which provides detailed information on each dataset and how to use them effectively. These datasets are invaluable resources for honing your data analysis and machine learning skills within the VerticaPy environment.

We can see that there are some extreme values in the data. We may need to clip those values at extremes. For this we can use the clip function.

vdf["vals"].clip(lower=0,upper=100)
123
vals
Integer
100%
10
20
30
40
510
620
7100

See also

vDataFrame.fillna() : Fill the missing values using the input method.
vDataColumn.fill_outliers() : Fill the outliers using the input method.