Notiz
Zougrëff op dës Säit erfuerdert Autorisatioun. Dir kënnt probéieren, Iech unzemellen oder Verzeechnesser ze änneren.
Zougrëff op dës Säit erfuerdert Autorisatioun. Dir kënnt probéieren, Verzeechnesser ze änneren.
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.
For the corresponding Databricks SQL function, see format_number function.
Syntax
from pyspark.sql import functions as dbf
dbf.format_number(col=<col>, d=<d>)
Parameters
| Parameter | Type | Description |
|---|---|---|
col |
pyspark.sql.Column or str |
the column name of the numeric value to be formatted |
d |
int |
the N decimal places |
Returns
pyspark.sql.Column: the column of formatted results.
Examples
from pyspark.sql import functions as dbf
df = spark.createDataFrame([(5,)], ["a"])
df.select("*", dbf.format_number("a", 4), dbf.format_number(df.a, 6)).show()