pyspark.sql.functions.format_number¶
-
pyspark.sql.functions.
format_number
(col, d)[source]¶ Formats the number X to a format like ‘#,–#,–#.–’, rounded to d decimal places with HALF_EVEN round mode, and returns the result as a string.
- Parameters
col – the column name of the numeric value to be formatted
d – the N decimal places
>>> spark.createDataFrame([(5,)], ['a']).select(format_number('a', 4).alias('v')).collect() [Row(v='5.0000')]
New in version 1.5.