pyspark.sql.DataFrame.agg

DataFrame.agg(*exprs)[source]

Aggregate on the entire DataFrame without groups (shorthand for df.groupBy().agg()).

New in version 1.3.0.

Examples

>>> df.agg({"age": "max"}).collect()
[Row(max(age)=5)]
>>> from pyspark.sql import functions as F
>>> df.agg(F.min(df.age)).collect()
[Row(min(age)=2)]