LoslegenKostenlos loslegen

Features from dates

Another feature engineering task to perform is month and year extraction. Perform this task on the date column of the ufo dataset.

Diese Übung ist Teil des Kurses

Preprocessing for Machine Learning in Python

Kurs anzeigen

Anleitung zur Übung

  • Print out the .head() of the date column.
  • Retrieve the month attribute of the date column.
  • Retrieve the year attribute of the date column.
  • Take a look at the .head() of the date, month, and year columns.

Interaktive Übung

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

# Look at the first 5 rows of the date column
print(____)

# Extract the month from the date column
ufo["month"] = ufo["date"].____

# Extract the year from the date column
ufo["year"] = ufo["date"].____

# Take a look at the head of all three columns
print(____)
Code bearbeiten und ausführen