Python
All Top 50 Python & Pandas Interview Questions#42
Fuzzy Time Series Matching with merge_asof() in Pandas
HardGoogleInterview Question #42
Asked at GoogleGiven `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| time | ticker | shares | bid_price |
|---|---|---|---|
| 09:30:05 | AAPL | 100 | 150.25 |
Expected Output Structure1 rows
| trade_time | ticker | shares | bid_price |
|---|---|---|---|
| 09:30:05 | AAPL | 100 | 150.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.