The task and original case
Match an event to the price known at that moment. This project tests whether your join respects time, not just whether it finds a nearby row. The artifact should make a future-information mistake visible with a small timeline and a deliberately unmatched early event.
| Case element | Value or requirement |
|---|---|
| Inputs | Prices 09:00=10 and 09:05=12; event at 09:03. |
| Build | An as-of join demonstration with an unmatched early-event test. |
This is an original invented exercise. It is independent practice, with no employer assessment or open-vacancy claim. Download the inputs, attempt your own result, then open the separate answer key.
Data and worked inputs
Build a result another person can follow
Keep price-effective times and event times as separate fields on a common time basis. The prices are 10 at 09:00 and 12 at 09:05; the event occurs at 09:03. Sort both tables in ascending time and choose the latest price whose timestamp is no later than the event.
pandas documents merge_asof for near-time matching. Use backward direction for this stated rule, and specify a by-key when extending to more than one item. Define whether an exact timestamp match is allowed; this exercise allows it. Keep the matched price time beside the event time and calculate its age, rather than returning only the price value.
Sources[1]
Check the worked result
The 09:03 event matches the 09:00 price of 10, which is three minutes old. The 09:05 price of 12 is later than the event and was unavailable under the stated timeline. Choosing the nearest price would pick 09:05 because it is only two minutes away, but violates the information rule.
An event at 08:59 has no eligible price. Preserve it as unmatched. A default fill using the first future price would erase precisely the condition this exercise is designed to detect.
Make the failure visible
Introduce duplicate price records at 09:00 with different values. Time alone no longer chooses an authoritative row, so define a version or reject the conflict. Also add another item with a price at 09:02; an ungrouped as-of join could attach the wrong item's price. Test maximum permitted price age if freshness matters to the question.
Revise it and ask someone to reproduce it
Move the event to 09:05 and predict a price of 12 under the exact-match rule. Then move it to 08:59 and verify that it remains unmatched. Ask a peer to reproduce all three outcomes from the timeline. Your next revision should explain any tolerance or version choice they could not infer.
- Matched price times never follow their events.
- Item identity and duplicate-time rules are visible.
- Early events remain unmatched with a clear status.
Describe the work accurately
After completing your own version, you could adapt this project bullet: “Built a time-aware practice price join that excludes future information and preserves unmatched early events.”
Use Projects or Independent practice as the heading. Keep the input files, result and revision together. Describe only your own completed work; the invented numbers are model outputs, not employer results or measured business impact.