Loading...

verticapy.vDataColumn.round#

vDataColumn.round(n: int) vDataFrame#

Rounds the vDataColumn by keeping only the input number of digits after the decimal point.

Parameters#

n: int

Number of digits to keep after the decimal point.

Returns#

vDataFrame

self._parent

Examples#

Let’s begin by importing 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.

Let us create a dummy dataset with float values:

vdf = vp.vDataFrame({"val" : [0.21, 11.26, 20.21]})
123
val
Numeric(6)
100%
10.21
211.26
320.21

AWe can conveniently round off the numbers and select the decimal point as well using n:

vdf["val"].round(n = 1)
123
val
Numeric(6)
100%
10.2
211.3
320.2

Note

While the same task can be accomplished using pure SQL (see below), adopting a Pythonic approach can offer greater convenience and help avoid potential syntax errors.

vdf["val"] = "ROUND(val, 1)"

See also

vDataColumn.abs() : Get the absolute value of a vDataColumn.
vDataFrame.abs() : Get the absolute value of mutiple vDataColumn.