0

Can someone help to resolve below issue :

I am trying to convert the string to date format in pyspark

datadf1 = datadf1.withColumn('vehicle_last_service_date_temp', to_date(datadf1.vehicle_last_service_date,"mm/dd/yyyy"))

TypeError: to_date() takes exactly 1 argument (2 given)
Suresh
  • 5,678
  • 2
  • 24
  • 40

1 Answers1

1

I am able to solve the above mention problem by using unix_timestamp:

import pyspark.sql.functions as F

datadf1 = datadf1.withColumn("vehicle_last_service_date_temp", 
                             F.date_format(F.to_date(F.unix_timestamp(datadf1.vehicle_last_service_date, "mm/dd/yyyy").cast("timestamp")), 'yyyy-MM-dd'))

As far as AWS glue issue for TypeError : to_date() takes exactly 1 argument (2 given).

There is must pyspark version issue, which glue is calling at the back end

titipata
  • 5,321
  • 3
  • 35
  • 59