dayofyear

In [ ]:
dayofyear(expr)

Returns the day of the year as an integer, where January 1 is day 1.

Parameters

Name Type Optional Description
expr
object
Expression.

Returns

str_sql : SQL expression.

Example

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

# Applying the dayofyear function
df["dayofyear_x"] = st.dayofyear(df["x"])
display(df)
📅
x
Timestamp
123
dayofyear_x
Integer
11993-11-03 12:00:00307
21959-09-05 03:00:00248
Rows: 1-2 | Columns: 2