pyspark.sql.functions.sum¶
-
pyspark.sql.functions.
sum
(col: ColumnOrName) → pyspark.sql.column.Column[source]¶ Aggregate function: returns the sum of all values in the expression.
New in version 1.3.0.
Changed in version 3.4.0: Supports Spark Connect.
- Parameters
- col
Column
or str target column to compute on.
- col
- Returns
Column
the column for computed results.
Examples
>>> df = spark.range(10) >>> df.select(sum(df["id"])).show() +-------+ |sum(id)| +-------+ | 45| +-------+