product
Returns the product of the values in a group.
Syntax
Python
from pyspark.sql import functions as sf
sf.product(col)
Parameters
Parameter | Type | Description |
|---|---|---|
|
| Column containing values to be multiplied together |
Returns
pyspark.sql.Column: the column for computed results.
Examples
Python
from pyspark.sql import functions as sf
df = spark.sql("SELECT id % 3 AS mod3, id AS value FROM RANGE(10)")
df.groupBy('mod3').agg(sf.product('value')).orderBy('mod3').show()
Output
+----+--------------+
|mod3|product(value)|
+----+--------------+
| 0| 0.0|
| 1| 28.0|
| 2| 80.0|
+----+--------------+