Lưu ý
Cần có ủy quyền mới truy nhập được vào trang này. Bạn có thể thử đăng nhập hoặc thay đổi thư mục.
Cần có ủy quyền mới truy nhập được vào trang này. Bạn có thể thử thay đổi thư mục.
Computes the factorial of the given value. Supports Spark Connect.
For the corresponding Databricks SQL function, see factorial function.
Syntax
from pyspark.sql import functions as dbf
dbf.factorial(col=<col>)
Parameters
| Parameter | Type | Description |
|---|---|---|
col |
pyspark.sql.Column or str |
a column to calculate factorial for. |
Returns
pyspark.sql.Column: factorial of given value.
Examples
from pyspark.sql import functions as dbf
spark.range(10).select("*", dbf.factorial('id')).show()
+---+-------------+
| id|factorial(id)|
+---+-------------+
| 0| 1|
| 1| 1|
| 2| 2|
| 3| 6|
| 4| 24|
| 5| 120|
| 6| 720|
| 7| 5040|
| 8| 40320|
| 9| 362880|
+---+-------------+