logoalt Hacker News

chrisaycocktoday at 12:58 AM0 repliesview on HN

Indeed, my very first attempt used numpy.searchsorted:

https://numpy.org/doc/2.2/reference/generated/numpy.searchso...

I couldn't figure-out how Arthur's bin matched on symbol though, so I switched to a linear scan on the right table to record the last-seen index for each "by" element. While it worked, my hash table was messy because I relied on Python to handle a whole tuple as a key, which had some issues during initial testing.

The asof join I wrote for Empirical properly categorizes the keys before they are matched. That approach worked far better.

https://www.empirical-soft.com/tutorial.html#dataframes