הערה
הגישה לדף זה מחייבת הרשאה. באפשרותך לנסות להיכנס או לשנות מדריכי כתובות.
הגישה לדף זה מחייבת הרשאה. באפשרותך לנסות לשנות מדריכי כתובות.
Returns time truncated to the unit.
Syntax
from pyspark.sql import functions as dbf
dbf.time_trunc(unit=<unit>, time=<time>)
Parameters
| Parameter | Type | Description |
|---|---|---|
unit |
pyspark.sql.Column or str |
The unit to truncate the time to. Supported units are: "HOUR", "MINUTE", "SECOND", "MILLISECOND", and "MICROSECOND". The unit is case-insensitive. |
time |
pyspark.sql.Column or str |
A time to truncate. |
Returns
pyspark.sql.Column: A time truncated to the specified unit.
Examples
from pyspark.sql import functions as dbf
df = spark.createDataFrame(
[("HOUR", "13:08:15")],
['unit', 'time']).withColumn("time", dbf.col("time").cast("time"))
df.select('*', dbf.time_trunc('unit', 'time')).show()