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