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.

Examples

>>> df = spark.createDataFrame([(5,)], ['n'])
>>> df.select(factorial(df.n).alias('f')).collect()
[Row(f=120)]