decode¶
In [ ]:
decode(expr, *argv)
Compares expression to each search value one by one.
Parameters¶
| Name | Type | Optional | Description |
|---|---|---|---|
expr | object | ❌ | Expression. |
argv | object | ❌ | Infinite Number of Expressions. The expression generated will look like: even: CASE ... WHEN expr = argv[2 * i] THEN argv[2 * i + 1] ... END odd : CASE ... WHEN expr = argv[2 * i] THEN argv[2 * i + 1] ... ELSE argv[n] END |
In [73]:
from verticapy import *
df = tablesample({"x": ['banana', 'apple', 'onion', 'potato']}).to_vdf()
display(df)
In [74]:
# Importing the stats module
import verticapy.stats as st
# Applying the decode function
df["type_x"] = st.decode(df["x"],
'banana', 'fruit',
'apple', 'fruit',
'vegetable')
display(df)
