pyspark.sql.functions.factorial¶
-
pyspark.sql.functions.
factorial
(col: ColumnOrName) → pyspark.sql.column.Column[source]¶ Computes the factorial of the given value.
New in version 1.5.0.
Changed in version 3.4.0: Supports Spark Connect.
- Parameters
- col
Column
or str a column to calculate factorial for.
- col
- Returns
Column
factorial of given value.
Examples
>>> df = spark.createDataFrame([(5,)], ['n']) >>> df.select(factorial(df.n).alias('f')).collect() [Row(f=120)]