01-detecting-missing-values found the gaps. Now you need to fill them, most ML operations (a matrix multiply, a gradient computation, a distance calculation) simply cannot proceed with a NaN sitting in the middle of an array, it poisons every computation that touches it. The simplest reasonable fill-in value for a missing number is "whatever's typical for that column," and there are two natural choices for "typical": the mean, and the median.
The choice between them isn't arbitrary, it's the exact same distinction 02-summarizing-a-distribution (the next track) makes between mean and median as measures of central tendency: one is sensitive to outliers, one isn't, and that sensitivity carries straight through into how good your imputed values end up being.
Theory fills each missing value with its own COLUMN's mean or median, computed only from that column's actually-observed values (ignoring the missing ones, not accidentally treating them as zero). Implement both, reusing 01-detecting-missing-values's mask to find exactly where to write the fill-in values.
Implement impute_with_mean(x) and impute_with_median(x) against that reasoning. The signatures and docstrings are already in the editor.
x, work on a copy.np.nanmean/np.nanmedian do this automatically).Open one at a time. Each gives away a little more than the last.
np.nanmean(x, axis=0) computes a length-num_columns array of column means, already ignoring NaNs, in one call.
missing_mask(x) (from 01-detecting-missing-values) tells you exactly which positions to overwrite; np.where(mask) gives you the row and column index of each one.
Click "Run Tests" to test your implementation