pyspark.sql.GroupedData.avg¶
-
GroupedData.
avg
(*cols: str) → pyspark.sql.dataframe.DataFrame¶ Computes average values for each numeric columns for each group.
- Parameters
- colsstr
column names. Non-numeric columns are ignored.
Examples
>>> df.groupBy().avg('age').collect() [Row(avg(age)=3.5)] >>> df3.groupBy().avg('age', 'height').collect() [Row(avg(age)=3.5, avg(height)=82.5)]