Loading...

verticapy.vDataColumn.div#

vDataColumn.div(x: int | float | Decimal) vDataFrame#

Divides the vDataColumn by the input element.

Parameters#

x: PythonNumber

Input number.

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

vdf = vp.vDataFrame({"val" : [10, -10, 20, -2]})
123
val
Integer
100%
110
2-10
320
4-2

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

vdf["val"].div(5)
123
val
Numeric(38)
100%
12.0
2-2.0
34.0
4-0.4

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

vDataColumn.mul() : Multiply the vDataColumn by a value.
vDataColumn.add() : Add a value to the vDataColumn.