apply

In [ ]:
apply(func: str, 
      *args, 
      **kwargs)

Applies any Vertica function on the input expressions. For a list of available functions, see the Vertica documentation.

Parameters

Name Type Optional Description
func
str
The name of a Vertica function. For geospatial functions, the ST_ or STV_ prefixes can be omitted.
args
object
Expressions.
kwargs
object
Optional Parameters Expressions.

Returns

str_sql : SQL expression.

Example

In [9]:
from verticapy import *
df = tablesample({"x": [11.4, -2.5, 3.5, -4.2]}).to_vdf()
display(df)
123
x
Numeric(3,1)
111.4
2-2.5
33.5
4-4.2
Rows: 1-4 | Column: x | Type: numeric(3,1)
In [10]:
# Importing the stats module
import verticapy.stats as st

# Applying the avg function
df["avg_x"] = st.apply("avg", df["x"])._over()
display(df)
123
x
Numeric(3,1)
123
avg_x
Float
111.42.05
2-2.52.05
33.52.05
4-4.22.05
Rows: 1-4 | Columns: 2