Loading...

vastorbit.VastColumn.mul

VastColumn.mul(x: Annotated[int | float | Decimal, 'Python Numbers']) VastFrame

Multiplies the VastColumn by the input element.

Parameters:

x (PythonNumber) – Input number.

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 some values:

vdf = vo.VastFrame({"val" : [10, -10, 20, -2]})
123
val
Integer
110
2-10
3-2
420
Rows: 1-4 | Column: val | Type: integer

We can conveniently multiply all the values in a column by 5:

vdf["val"].mul(5)
123
val
Integer
1100
2-10
3-50
450
Rows: 1-4 | Column: val | Type: integer

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"] = "val * 5"

See also

VastColumn.add() : Add a value to the entire VastColumn.
VastColumn.div() : Divide the VastColumn by a value.