PySpark Dataframe : comma to dot

Viewed 9858

I have imported data using comma in float numbers and I am wondering how can I 'convert' comma into dot. I am using pyspark dataframe so I tried this :

commaToDot = udf(lambda x : str(x).replace(',', '.'), FloatType())

myData.withColumn('area',commaToDot(myData.area))

And it definitely does not work. So can we replace directly it in dataframe from spark or should we switch in numpy type or something else ?

Thanks !

2 Answers
Related