pyspark.sql.GroupedData.sum

GroupedData.sum(*cols: str) → pyspark.sql.dataframe.DataFrame

Computes the sum for each numeric columns for each group.

Parameters
colsstr

column names. Non-numeric columns are ignored.

Examples

>>> df.groupBy().sum('age').collect()
[Row(sum(age)=7)]
>>> df3.groupBy().sum('age', 'height').collect()
[Row(sum(age)=7, sum(height)=165)]