0PricingLogin
Data Science Academy · Lesson

Extract Year, Month, and Weekday

Using the dt accessor for features.

A Timestamp Holds a Lot

One datetime value packs a year, month, day, hour, and weekday inside it. The skill is pulling each piece out as its own column for analysis. 🧩

Meet the dt Accessor

On a datetime column, the dt accessor is your gateway. It exposes every date part as a simple attribute you can read or assign.

df["date"].dt  # gateway to date parts

All lessons in this course

  1. Parse Strings Into Datetimes
  2. Extract Year, Month, and Weekday
  3. Resample to Daily or Monthly
  4. Time Zones and Date Ranges
← Back to Data Science Academy