BuildlyBuildly
DashboardExercisesProfileHelp
Data Science/Module 3: Importing & Handling Files/Dates & Times1/3
Exercise·7 min·10 XP

Extract the Month from Dates

Context. You have a column of dates and want to group sales by month — first you need the month number out of each date.

Your task. Write extract_months(df) that parses the date column and returns a Series of month numbers (1-12).

Example. "2021-03-15" → 3, "2021-12-01" → 12.

Notes. Return a Series of integers. Parse the text to datetime first, then reach for the month.

Previous
Parse a Date Column
Next
Filter Rows by Year