pyspark.sql.functions.factorial

pyspark.sql.functions.factorial(col: ColumnOrName) → pyspark.sql.column.Column

Computes the factorial of the given value.

Examples

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