Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Returns the product of the values in a group.
Syntax
from pyspark.sql import functions as sf
sf.product(col)
Parameters
| Parameter | Type | Description |
|---|---|---|
col |
pyspark.sql.Column or column name |
Column containing values to be multiplied together |
Returns
pyspark.sql.Column: the column for computed results.
Examples
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()
+----+--------------+
|mod3|product(value)|
+----+--------------+
| 0| 0.0|
| 1| 28.0|
| 2| 80.0|
+----+--------------+