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.
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|
+---+-------------+