LoslegenKostenlos loslegen

Replace missing values with the median value

Given is a basetable that has a predictive variable age of the donors that has missing values in it. It is a good idea to replace these missing values by the median age of the donors.

Diese Übung ist Teil des Kurses

Intermediate Predictive Analytics in Python

Kurs anzeigen

Anleitung zur Übung

  • Calculate the median age of all donors and assign this value to median_age.
  • Replace missing values in age by median_age.
  • Calculate the median age of all donors after the replacement is done.

Interaktive Übung

Versuche dich an dieser Übung, indem du diesen Beispielcode vervollständigst.

# Calculate the median of age
median_age = ____["____"].____()
print(median_age)

# Replace missing values by the median
basetable["age"] = ____["____"].____(____)

# Calculate the median of age after replacement
median_age = ____["____"].____()
print(median_age)
Code bearbeiten und ausführen