concept average enrollment in category spark

appears as: average enrollment
Spark in Action, Second Edition

This is an excerpt from Manning's book Spark in Action, Second Edition.

What is the average enrollment for each school?

To compute the average enrollment for each school, per year, you will have to group the dataset by school and year. In the same operation, you can also add the average presence and absence for the school.

Listing 15.14 Code to compute the average enrollment for each NYC school
Dataset<Row> averageEnrollmentDf = masterD f
col( "schoolId" ), col( "schoolYear" )) #1
            .avg( "enrolled" , "present" , "absent" ) #2
             .orderBy( "schoolId" , "schoolYear" ); #3