在不添加新列的情况下,将同一数据帧中的from_unixtime转换为to_utc_timestamp,可以使用Spark SQL中的函数来实现。
首先,需要导入Spark SQL的函数库:
from pyspark.sql.functions import expr
然后,使用withColumn
函数将from_unixtime
列转换为to_utc_timestamp
列:
df = df.withColumn("to_utc_timestamp", expr("to_utc_timestamp(from_unixtime(from_unixtime_column), 'UTC')"))
其中,df
是数据帧,from_unixtime_column
是包含Unix时间戳的列名。
这样,就可以将同一数据帧中的from_unixtime
转换为to_utc_timestamp
,并且不需要添加新列。
请注意,以上代码是使用Spark SQL的方式进行转换,如果使用其他编程语言或工具,可能会有不同的实现方式。
没有搜到相关的结果
领取专属 10元无门槛券
手把手带您无忧上云