【发布时间】:2021-03-01 03:51:57
【问题描述】:
我目前正在尝试将以毫秒为单位的纪元格式存储的日期转换为时间戳。
.withColumn(
"date_var",
from_utc_timestamp(
from_unixtime("timestamp_var" / 1000, "yyyy-MM-dd HH:mm:ss"), "PST"
)
不幸的是,这是错误的:
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-37-df435784865f> in <module>
32 "date_var",
33 from_utc_timestamp(
---> 34 from_unixtime("timestamp_var" / 1000, "yyyy-MM-dd HH:mm:ss"), "PST"
35 ),
36 )
TypeError: unsupported operand type(s) for /: 'str' and 'int'
我不确定我的语法有什么问题,但欢迎任何帮助!
谢谢!
【问题讨论】:
标签: python datetime unix pyspark epoch