Loading...

verticapy.sql.functions.apply#

verticapy.sql.functions.apply(func: str | list[str] | StringSQL | list[StringSQL], *args, **kwargs) StringSQL#

Applies any Vertica function on the input expressions. Please check-out the Vertica Documentation to see the available functions: https://www.vertica.com/docs/

Parameters#

func: SQLExpression

Vertica Function. For geospatial functions, you can write the function name without the ST_ or STV_ prefix.

args: SQLExpression, optional

Expressions.

kwargs: SQLExpression, optional

Optional Parameters Expressions.

Returns#

StringSQL

SQL string.

Examples#

First, let’s import the vDataFrame in order to create a dummy dataset.

from verticapy import vDataFrame

Now, let’s import the VerticaPy SQL functions.

import verticapy.sql.functions as vpf

We can now build a dummy dataset.

df = vDataFrame({"x": [11.4, -2.5, 3.5, -4.2]})

Now, let’s go ahead and apply the function.

df["avg_x"] = vpf.apply("avg", df["x"])._over()
display(df)
123
x
Numeric(5)
100%
123
avg_x
Float(22)
100%
111.42.05
2-2.52.05
33.52.05
4-4.22.05

Note

It’s crucial to utilize VerticaPy SQL functions in coding, as they can be updated over time with new syntax. While SQL functions typically remain stable, they may vary across platforms or versions. VerticaPy effectively manages these changes, a task not achievable with pure SQL.

See also

vDataFrame.eval() : Evaluates the expression.