How to convert yyyymmddhhmmss in PySpark dataframe.
Example: 20180718093158 is my input and I want the result like 2018-07-18 09:31:58
How to convert yyyymmddhhmmss in PySpark dataframe.
Example: 20180718093158 is my input and I want the result like 2018-07-18 09:31:58
First, cast your "date" column to string and then apply to_timestamp() function with format "yyyyMMddHHmmSS" as the second argument, i.e.
from pyspark.sql import functions as F
df = withColumn(
"date",
F.to_timestamp(F.col("date").cast("string"), "yyyyMMddHHmmSS")
)