Working with Dates
The dt accessor reads year, month and weekday. date_range makes sequences.
Example
s = pd.to_datetime(pd.Series(["2026-01-05", "2026-02-10"]))
print(s.dt.year.tolist(), s.dt.month_name().tolist(), s.dt.dayofweek.tolist())
print(pd.date_range("2026-01-01", periods=3, freq="D").strftime("%d %b").tolist())Result
[2026, 2026] ['January', 'February'] [0, 1] ['01 Jan', '02 Jan', '03 Jan']
Exercise
Month number.
s.dt.Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.