Loading...

vastorbit.VastColumn.round

VastColumn.round(n: int) VastFrame

Rounds the VastColumn 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:

self._parent

Return type:

VastFrame

Examples

Let’s begin by importing vastorbit.

import vastorbit as vo

Hint

By assigning an alias to vastorbit, we mitigate the risk of code collisions with other libraries. This precaution is necessary because vastorbit 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 vastorbit are used as intended without interfering with functions from other libraries.

Let us create a dummy dataset with float values:

vdf = vo.VastFrame({"val" : [0.21, 11.26, 20.21]})
123
val
Decimal(4, 2)
120.21
211.26
30.21
Rows: 1-3 | Column: val | Type: decimal(4, 2)

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

vdf["val"].round(n = 1)
123
val
Decimal(5, 2)
111.3
20.2
320.2
Rows: 1-3 | Column: val | Type: decimal(5, 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

VastColumn.abs() : Get the absolute value of a VastColumn.
VastFrame.abs() : Get the absolute value of mutiple VastColumn.