Downsampling aggregates high-frequency data (e.g., ticks → daily). Upsampling fills gaps in lower-frequency data (e.g., monthly → daily with interpolation). Proper frequency alignment prevents lookahead bias and ensures your features match your target.
A day of +10% and a day of −10%: summing the returns says 0%, compounding says −1%. Summing log returns gives the right −1%. And a week of prices ending at 95 has a closing price of 95 but an average of 101.2: whether you take the last value, the mean, the sum or the maximum is a modelling decision.
- Downsampling with the wrong aggregate (mean of prices, sum of rates) silently changes what the series means.
- Upsampling invents data points; forward-filling makes series look smoother and more autocorrelated than they are.
- Calendar periods differ in length (months, trading days), which matters for sums and rates.
daily = np.array([0.10, -0.10]) # +10% then -10%
summed = daily.sum()
compounded = np.prod(1 + daily) - 1
log_sum = np.expm1(np.log1p(daily).sum()) # log returns add up correctly
prices = pd.Series([100, 102, 101, 108, 95], index=pd.date_range('2026-03-02', periods=5))
week = dict(last=prices.iloc[-1], mean=prices.mean()) # a weekly 'close' vs a weekly averageAssumes import numpy as np and import pandas as pd. Each snippet simulates or makes up its own series, as the comments say.
The same idea with a library
# Python — resampling with pandas # Downsample: daily → weekly (OHLCV) weekly = df.resample('W').agg({ 'open': 'first', 'high': 'max', 'low': 'min', 'close': 'last', 'volume': 'sum' }) # Upsample: monthly → daily (forward fill) daily = monthly.resample('D').ffill()
- R. S. Tsay, Analysis of Financial Time Series (3rd ed.), Wiley, 2010 — simple versus log returns
- pandas documentation, “Time series / date functionality: resampling”, pandas.pydata.org
- Forecasting: Principles and Practice (3rd ed.), R. J. Hyndman & G. Athanasopoulos, OTexts, 2021
Last reviewed October 2026 · How this site checks its content · Report a mistake
- MLOps & Production MLQuantizationFP32 → INT8 — trading precision for speed
- MLOps & Production MLServing PatternsReal-time vs batch vs streaming — choosing your inference architecture
- The ToolkitMissing Data StrategiesImputation, MICE, missingness patterns — handling gaps without corrupting your analysis