[英]Question on pyspark data frame for timestamp
I have a dataframe in which one of the column is a time stamp.我有一个 dataframe 其中一列是时间戳。
enter image description here在此处输入图像描述
How can i create another data frame from this column in the below format如何从该列以以下格式创建另一个数据框
enter image description here在此处输入图像描述
Can i get some help here please?我可以在这里得到一些帮助吗?
Let's say your timestamp column name is time:假设您的时间戳列名称是时间:
from pyspark.sql.functions import *
df2 = df1.withColumn('year',year('time')).withColumn('quarter',quarter('time')).withColumn('weekOfTheYear',weekofyear('time')).withColumn('dayOfTheWeek', dayofweek('time')).withColumn('dayofmonth',dayofmonth('time'))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.