← NumPy & Pandas learning path
NumPy & Pandas · Module 9 of 10

Time series and dates

Work with dates, times and time-based data.

📖 Key ideas

  1. Convert with pd.to_datetime; access parts with .dt.year, .dt.month.
  2. Set a date index for time series.
  3. resample("M").sum() aggregates by month.
  4. rolling(7).mean() computes moving averages.
  5. 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