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#
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)
123xNumeric(5)100%123avg_xFloat(22)100%1 11.4 2.05 2 -2.5 2.05 3 3.5 2.05 4 -4.2 2.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.