I've a dataframe where the date/time column is of string datatype and looks something like "Tue Apr 21 01:16:19 2020"
. How do I convert this to a date column with format as 2020/04/21
in pyspark.
I tried something like this,
option1:
df = df.withColumn("event_time2",from_unixtime(unix_timestamp(col("Event_time"), 'MM/dd/yyy')))
option2:
df= df.withColumn("event_time2",unix_timestamp(col("Event_time"),'yyyy-MM-dd HH:mm:ss').cast("timestamp"))
but both return null