pyspark.sql.functions.
avg
Aggregate function: returns the average of the values in a group.
New in version 1.3.0.
Changed in version 3.4.0: Supports Spark Connect.
Column
target column to compute on.
the column for computed results.
Examples
>>> df = spark.range(10) >>> df.select(avg(col("id"))).show() +-------+ |avg(id)| +-------+ | 4.5| +-------+