← NumPy & Pandas learning pathNumPy & Pandas · Module 9 of 10
Time series and dates
Work with dates, times and time-based data.
📖 Key ideas
- Convert with pd.to_datetime; access parts with .dt.year, .dt.month.
- Set a date index for time series.
- resample("M").sum() aggregates by month.
- rolling(7).mean() computes moving averages.
- shift() compares with previous periods.
💡 Real-life example: Resampling is turning daily diary entries into monthly summaries.
.dt accessorDate parts of a datetime column
resampleChanges time frequency
rollingMoving window calculations
shiftMoves data by periods