[英]Convert column of timestamp integer to Datetime that stop after the hour in a spark Dataframe
You can cast the Date column to timestamp with the required format.您可以将日期列转换为所需格式的时间戳。
from pyspark.sql.functions import to_timestamp
df = df.withColumn("new_date", to_timestamp("Date", "yyyyMMdd"))
Note* you asked for the hour also but I don't see that you have in your Date column hour information.注意*您还询问了小时,但我没有看到您的日期列中包含小时信息。 If you have just add it to the format ,for example:如果您刚刚将其添加到格式中,例如:
df = df.withColumn("new_date", to_timestamp("Date", "yyyyMMdd HHmmss"))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.