hour

In [ ]:
hour(expr)

Returns the hour portion of the specified date as an integer, where 0 is 00:00 to 00:59.

Parameters

Name Type Optional Description
expr
object
❌
Expression.

Returns

str_sql : SQL expression.

Example

In [8]:
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 [9]:
# Importing the stats module
import verticapy.stats as st

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