Python Spark-将时间戳转换为YYYY-MM-DD

时间:2020-01-06 17:36:53

标签: python pyspark timestamp

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

示例:

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

期望的输出:2017年3月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

1 个答案:

答案 0 :(得分:0)

我想你在“)”末尾错过了一个括号。