Piezīmes
Lai piekļūtu šai lapai, ir nepieciešama autorizācija. Varat mēģināt pierakstīties vai mainīt direktorijus.
Lai piekļūtu šai lapai, ir nepieciešama autorizācija. Varat mēģināt mainīt direktorijus.
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|
+---+-------------+