birth_date我有一个以这种格式调用的整数列:20141130
我想将其转换为2014-11-30PySpark 中的内容。
这会错误地转换日期:
.withColumn("birth_date", F.to_date(F.from_unixtime(F.col("birth_date"))))
Run Code Online (Sandbox Code Playgroud)
这给出了一个错误:argument 1 requires (string or date or timestamp) type, however, 'birth_date' is of int type
.withColumn('birth_date', F.to_date(F.unix_timestamp(F.col('birth_date'), 'yyyyMMdd').cast('timestamp')))
Run Code Online (Sandbox Code Playgroud)
将其转换为我想要的日期的最佳方法是什么?