vastorbit.VastFrame.abs¶
- VastFrame.abs(columns: Annotated[str | list[str], 'STRING representing one column or a list of columns'] | None = None) VastFrame¶
Applies the absolute value function to all input VastColumns.
- Parameters:
columns (SQLColumns, optional) – List of the VastColumns names. If empty, all numerical VastColumns are used.
- Returns:
self
- Return type:
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 fromvastorbitare used as intended without interfering with functions from other libraries.Let us create a dummy dataset with negative values:
vdf = vo.VastFrame({"val" : [10, -10, 20, -2]})
123valInteger1 20 2 -2 3 -10 4 10 Rows: 1-4 | Column: val | Type: integerNow we can convert all to absolute values:
vdf.abs()
123valInteger1 10 2 20 3 10 4 2 Rows: 1-4 | Column: val | Type: integerNote
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"] = "ABS(val)"
See also
VastFrame.analytic(): Advanced Analytical functions.