I have a date pyspark dataframe with a string column in the format of MM-dd-yyyy and I am attempting to convert this into a date column.
MM-dd-yyyy
I tried:
In the accepted answer's update you don't see the example for the to_date function, so another solution using it would be:
to_date
from pyspark.sql import functions as F df = df.withColumn( 'new_date', F.to_date( F.unix_timestamp('STRINGCOLUMN', 'MM-dd-yyyy').cast('timestamp')))