You can use the function format_number as
import org.apache.spark.sql.functions.format_number
df.withColumn("NumberColumn", format_number($"NumberColumn", 5))
here 5 are the decimal places you want to show
As can be seen from the above format_numberfunction format_number, the string column is returned.
format_number (column x, int d)
Formats a numeric column x in a format such as' #, ###, ###. ## ', rounded to decimal places d, and returns the result as a string column.
, regexp_replace
regexp_replace ( e, , )
, rep.
import org.apache.spark.sql.functions.regexp_replace
df.withColumn("NumberColumn", regexp_replace(format_number($"NumberColumn", 5), ",", ""))
, (,) .