week

In [ ]:
week(expr)

Returns the week of the year for the specified date as an integer, where the first week begins on the first Sunday on or preceding January 1.

Parameters

Name Type Optional Description
expr
object
Expression.

Returns

str_sql : SQL expression.

Example

In [20]:
from verticapy import *
df = tablesample({"x": ['11-03-1993 12:05:10.23', '09-05-1959 03:10:20.12']}).to_vdf()
df["x"].astype("timestamp")
display(df)
📅
x
Timestamp
11993-11-03 12:05:10.230000
21959-09-05 03:10:20.120000
Rows: 1-2 | Column: x | Type: timestamp
In [21]:
# Importing the stats module
import verticapy.stats as st

# Applying the week function
df["week_x"] = st.week(df["x"])
display(df)
📅
x
Timestamp
123
week_x
Integer
11993-11-03 12:05:10.23000045
21959-09-05 03:10:20.12000036
Rows: 1-2 | Columns: 2