Python
#42

Fuzzy Time Series Matching with merge_asof() in Pandas

HardGoogle
Interview Question #42
Asked at Google

Given `trades` (trade_time, ticker, shares) and `quotes` (quote_time, ticker, bid_price), match each trade to the most recent quote available on or before the trade time using `pd.merge_asof()`.

Input Table: trades & quotes
1 rows preview
timetickersharesbid_price
09:30:05AAPL100150.25
Expected Output Structure1 rows
trade_timetickersharesbid_price
09:30:05AAPL100150.25
Interview Context

Asked frequently in data analyst and business analyst technical rounds. Focus on clean filtering, optimal indexing usage, and unambiguous column selection.

Python 3.10 (Pandas)
Environment Ready

Click "Run & Test" to execute your Pandas code against the test assertions.

Chat with us