I'm using the following function to parse string to date in PySpark
func = udf(lambda x: parser.parse(x), DateType())
My date format is:
"22-Jan-2021 00:00"
Althought this function does not work with None types, I have the following Spark data frame
date
----
"22-Jan-2021 00:00"
""
"10-Feb-2020 14:00"
When I apply my func to the date column I got an error on the second line of DF saying that it can't parse NoneType. Any tips to solve this problem using PySpark and the above func ?
An MVCE:
date = None
date_parsed = parser.parse(date)