df.groupBy("Profession").agg({'Age':'avg', 'Gender':'count'}).show()
from pyspark.sql import functions as F df.groupBy("Profession").agg(F.mean('Age'), F.count('Age')).show()