DataFrame.
agg
Aggregate on the entire DataFrame without groups (shorthand for df.groupBy().agg()).
DataFrame
df.groupBy().agg()
New in version 1.3.0.
Changed in version 3.4.0: Supports Spark Connect.
Column
Columns or expressions to aggregate DataFrame by.
Aggregated DataFrame.
Examples
>>> from pyspark.sql import functions as F >>> df = spark.createDataFrame([(2, "Alice"), (5, "Bob")], schema=["age", "name"]) >>> df.agg({"age": "max"}).show() +--------+ |max(age)| +--------+ | 5| +--------+ >>> df.agg(F.min(df.age)).show() +--------+ |min(age)| +--------+ | 2| +--------+