Session Ready
Exercise

Analyzing datetime columns

Feature engineering is an important step in all machine learning workflows in order to process features from different data types. In particular, datetime columns are common in many datasets. In this exercise, you will explore the hour column in the dataset, which is stored as an integer but represents a datetime. First you will parse the hour column to convert it into a datetime column. Then you will extract the hour of the day from that datetime column, and calculate the total number of clicks based on that hour of the day.

The pandas module is available as pd in your workspace and the sample DataFrame is loaded as df.

Instructions
100 XP
  • Convert the hour column from an integer to a datetime column using pd.to_datetime().
  • Using the datetime accessor .dt, extract the hour field from the converted column using .hour.
  • Compute total clicks by the extracted hour of day using .sum().