Implement a Custom Resampler for Time Series Data in Pandas

Instruction: Using pandas and NumPy, aggregate finite numeric observations or missing values into left-closed, left-labelled UTC hourly bins. Weight observations by elapsed time with a 30-minute half-life, normalize within each bin, and return missing for empty/all-missing bins. Demonstrate with timestamps 2026-01-01 00:00Z, 00:30Z, 01:05Z and 03:00Z, with values 10, 20, 100 and missing. Explain the output and when a completed bin is available.

Context: This question tests the candidate's ability to manipulate time series data, their understanding of advanced indexing and resampling techniques in Pandas, and their skill in applying custom operations to grouped data.

Updated

Official answer available

Read the opening below, then unlock the full answer and practical guidance.

Use actual elapsed time, not row position. With a 30-minute half-life, an observation 30 minutes older than another receives half its weight. Multiplying every weight by the same parameter would cancel during normalization and would not control decay.

For finite numeric observations or missing values, this pandas/NumPy example computes a separate weighted mean in each left-closed UTC hour:...

Related Questions