Working with dates, and indexing by more than one level at once.
import pandas aspdimport numpy asnp
s = pd.Series(np.arange(10, dtype=float), index=pd.date_range("2020-01-01", periods=10, freq="D"))
print(s.resample("3D").mean()) # aggregate into fixed time bucketsprint(s.shift(1)) # lag by one periodprint(s.rolling(window=3).mean()) # rolling / moving averageprint(s.index.month) # the .dt / DatetimeIndex accessor
A MultiIndex lets a DataFrame be indexed by more than one key at once.
This is common after a groupby on multiple columns, or when representing
naturally hierarchical data like (date, ticker).
💡 Tip: np.busday_offset(dates, offsets=-10, roll='backward') shifts dates by business days, rolling non-business days back to the nearest valid one first.