pyspark.sql.functions.
factorial
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)]