groupby in pyspark code example
Example 1: Pyspark Aggregation on multiple columns
df.groupBy("year", "sex").agg(avg("percent"), count("*"))
Example 2: pyspark group by and average in dataframes
df.groupBy("Profession").agg({'Age':'avg', 'Gender':'count'}).show()