CommencerCommencer gratuitement

Fill dummy values

Similar to how you tried to find any relation of missing to missing values between columns, it is also important to find any relation of missing to non-missing values between columns. This will help you realize any factors for missingness in the data.

BMI vs Serum Insulin

In the above figure, you can observe that the missing values of Serum Insulin are spread across the range of BMI values. This only implies that there is no relation!

In this exercise, you will write a function to generate dummy values to help create the above scatter plot (in the next exercise). The operations to generate dummy values involve scaling the random values to a column range with a scaling factor and shifting the values.

The function rand() has been imported for you from numpy.random.

Cet exercice fait partie du cours

Dealing with Missing Data in Python

Afficher le cours

Exercice interactif pratique

Essayez cet exercice en complétant cet exemple de code.

def fill_dummy_values(df):
  df_dummy = df.copy(deep=True)
  for col_name in df_dummy:
    col = df_dummy[col_name]
    # Calculate column range
    col_range = ___ - ___
  return df_dummy
Modifier et exécuter le code