mean function

The mean function displays the average attribute value calculated mathematically. It is the sum of the values divided by the number of values. (E.g.: the mean between 2; 3; 10 is 5).

This function doesn’t work with nominal attributes. For nominal attributes you can use the mode function.


Function and parameters

mean(column, group)

Parameter

Description

column

It identifies the column to which you want to apply the formula. The column parameter is mandatory.

group

It allows you to group the results by a certain column.


Example

The following example uses the Students Performance dataset.

Description

Screenshot

  • In the example here, we want to retrieve the mean of the math score attribute.

  • We write the following formula:

  • mean($"math score")

So, the mean of the math score attribute is 66.089.

  • We also want to group our results by the test preparation course attribute, so the formula will become:

  • mean($"math score",$"test preparation course")

  • The results are as follows:

    • The mean of the math score of those who have done no test preparation course (none) is 64.078.

    • The mean of the math score of those who have completed the test preparation course is 69.696.