【问题标题】:Python Spark - Convert timestamp into YYYY-MM-DDPython Spark - 将时间戳转换为 YYYY-MM-DD
【发布时间】:2020-01-06 17:36:53
【问题描述】:

我目前正在尝试在 Python Spark 上将时间戳转换为日期格式 YYYY-MM-DD

例子:

table = random_name
start_time: 2017-03-25T12:58:16.000+0000

期望输出:2017-03-25

start_time: timestamp

代码:

x = spark.table(random_name)

display(x.withColumn('ts', to_timestamp(col('start_time')))
          .withColumn('new_start_date', to_date(col('ts')))

但我得到了这个

SyntaxError: 解析时出现意外的 EOF

【问题讨论】:

    标签: python pyspark timestamp


    【解决方案1】:

    我猜你错过了末尾的括号“)”

    【讨论】:

      猜你喜欢
      • 2013-03-24
      • 1970-01-01
      • 2022-08-03
      • 1970-01-01
      • 1970-01-01
      • 2022-12-07
      • 1970-01-01
      • 2014-06-11
      • 1970-01-01
      相关资源
      最近更新 更多