A date column in a file(In AWS S3) is in "July 28, 2021" Format.Since it is a file it is being treated as String datatype.I am trying to load the data in to RDS(Postgres). The RDS Column is in date datatype.
I am using the below line to convert the string into date but NULLS getting loaded in the date column , rest string/integer columns are getting loaded correctly. df_S3=df_S3.withColumn('visit_date', to_date(df_S3.visit_date, 'MON DD, YYYY'))
I changed the date from "July 28, 2021" to "28-JUL-2021" in the S3 File and used the below line of code to process the data into RDS - df_S3=df_S3.withColumn('visit_date', to_date(df_S3.visit_date, 'DD-MMM-YYYY'))
And dates got loaded correctly into RDS.
Could you please advise how to convert/load "July 28, 2021" into a date datatype column using PySpark ?
Thanks.
source https://stackoverflow.com/questions/70174472/processing-strings-into-date-datatype-column-in-rds-using-pyspark
Comments
Post a Comment