Hi Sid,

df = df.withColumn("annual_salary",
regexp_replace(col("annual_salary"), "\.", ""))

 The value 125.06 becomes 12506 which when cast to double is 12506.00


Have you tried without removing the . ?

df.withColumn("annual_salary",
round(col("annual_salary").cast("double"), 2)).show(truncate=False)




On Sun, 29 May 2022 at 20:25, Sid <flinkbyhe...@gmail.com> wrote:

> Hi Team,
>
> I need help with the below problem:
>
>
> https://stackoverflow.com/questions/72422872/unable-to-format-double-values-in-pyspark?noredirect=1#comment127940175_72422872
>
>
> What am I doing wrong?
>
> Thanks,
> Siddhesh
>

Reply via email to