Advanced missing data
In the previous exercise, you saw how to identify how many missing values are in each column of a DataFrame, and then you can simply drop any rows that have missing values. However, what if there are a lot of rows with missing values? What if you don't simply want to start deleting rows from the data? This is where the concept of replacement comes in - you can replace the missing values with something else.
In this exercise, you will work with the same sales_df
DataFrame as in the last exercise, but instead of dropping missing values, you will replace the missing values in each column with the average of all non-missing values. You will write a function that can then be applied to any column in a DataFrame.
This exercise is part of the course
Intermediate Julia
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Define a function replace_missing that takes one argument, the name of the column we want to modify
____ replace_missing(____)
end