In the context of this exercise, what if we wanted to get the mean of the values, rather than the percentage of the values, that met some condition?
To get the mean of specific values, instead of the percentage of values, satisfying some condition, we can obtain that with a few easy steps.
Say we had an array of temperature values ranging from 0 to 100, and wanted to get the average of temperatures greater than 50.
First, we would select the specific data based on a condition, which will create a new array of all temperatures greater than 50.
temperatures[temperatures > 50]
Finally, we apply the
np.mean() function to this data, which will give us the mean of the values.
np.mean(temperatures[temperatures > 50])