BaşlayınÜcretsiz Başlayın

Adding age with timegap

The basetable of previous exercise is given. The timeline is given below, there is a timegap of one month. In this exercise, you will learn how to add the age of the donors to the basetable, compliant with the timeline.

Bu egzersiz

Intermediate Predictive Analytics in Python

kursunun bir parçasıdır
Kursu Görüntüle

Egzersiz talimatları

  • Fill out the reference date on which the age should be calculated, this is the start date of the timegap.
  • Add a column "age" to the basetable that is the age of the donor on the reference date. The function calculate_age has been implemented for you. It takes date_of_birth and reference_date as arguments.
  • Print the mean age of all donors.

Uygulamalı interaktif egzersiz

Bu örnek kodu tamamlayarak bu egzersizi bitirin.

# Reference date
reference_date = datetime.date(____, ____, ____)

# Add age to the basetable
basetable["age"] = (pd.Series([calculate_age(____, ____)
                              for date_of_birth in basetable["date_of_birth"]]))

# Calculate mean age
print(round(basetable["____"].____()))
Kodu Düzenle ve Çalıştır