vDataFrame[].apply¶
In [ ]:
vDataFrame[].apply(func: str,
copy_name: str = "")
Applies a function to the vcolumn.
Parameters¶
| Name | Type | Optional | Description |
|---|---|---|---|
func | str | ❌ | Function to use to transform the vcolumn. It must be pure SQL. The function variable must be composed of two flower brackets {}. For example to apply the function: x -> x^2 + 2 use "POWER({}, 2) + 2". |
copy_name | str | ✓ | Name of the copy if the 'copy' parameter is set to True. |
Returns¶
vDataFrame : self.parent
Example¶
In [16]:
from verticapy.datasets import load_titanic
titanic = load_titanic()
display(titanic["age"])
In [15]:
# the variable must be composed of two flower brackets '{}' and only pure SQL works
titanic["age"].apply(func = "POWER({}, 2)")
Out[15]:
In [17]:
# creating a new vcolumn to compute the result of the transformation
titanic["age"].apply(func = "POWER({}, 2)",
copy_name = "age_pow_2")
Out[17]:
See Also¶
| vDataFrame.apply | Applies functions to the input vcolumns. |
| vDataFrame.applymap | Applies a function to all the vcolumns. |
| vDataFrame.eval | Evaluates a customized expression. |
