extract¶
In [ ]:
extract(expr, field: str)
Extracts a sub-field such as year or hour from a date/time expression.
Parameters¶
| Name | Type | Optional | Description |
|---|---|---|---|
expr | object | ❌ | Expression. |
field | str | ❌ | The field to extract. It must be one of the following: CENTURY / DAY / DECADE / DOQ / DOW / DOY / EPOCH / HOUR / ISODOW / ISOWEEK / ISOYEAR / MICROSECONDS / MILLENNIUM / MILLISECONDS / MINUTE / MONTH / QUARTER / SECOND / TIME ZONE / TIMEZONE_HOUR / TIMEZONE_MINUTE / WEEK / YEAR |
In [2]:
from verticapy import *
df = tablesample({"x": ['11-03-1993', '12-03-1993']}).to_vdf()
df["x"].astype("timestamp")
display(df)
In [3]:
# Importing the stats module
import verticapy.stats as st
# Applying the extract function
df["months"] = st.extract(df["x"], "MONTH")
display(df)
