Query Set #7b – imputing missing temperature values using mean imputation

Here, we use mean imputation instead of normal-value imputation to fill in the missing temperature value. As such, the 98.6 value from Query Set #7a is replaced with a SELECT-FROM-WHERE block that finds the mean of the temperature variable (98.4, in this case) where it is not missing. The AVG() function returns the mean of a collection of values. The AVG() function and similar functions (MIN(), MAX(), COUNT(), SUM(), and so on) are termed aggregate functions because they describe an aggregation of values using a single value:

sqlite> UPDATE MORT_FINAL_2 SET Temp_f = 
(SELECT AVG(Temp_f)
FROM MORT_FINAL_2
WHERE Temp_f IS NOT NULL)
WHERE Temp_f IS NULL;
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset