Бележка
Достъпът до тази страница изисква удостоверяване. Можете да опитате да влезете или да промените директориите.
Достъпът до тази страница изисква удостоверяване. Можете да опитате да промените директориите.
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.databricks.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.databricks.sql import functions as dbf
df = spark.createDataFrame([(5,)], ["a"])
df.select("*", dbf.format_number("a", 4), dbf.format_number(df.a, 6)).show()