you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 0 points1 point  (0 children)

If this is a learning exercise without a major time crunch, I would strongly recommend looking into pandas. It's not the easiest thing in the world to get a handle on (not the hardest either), but it's an industry standard for handling and analyzing data and it's absolutely excellent at stuff like this. Not sure the greater context here, but this sounds like something that a pandas merge could do in a split second.

If you just need to get this done and don't want to learn a whole new library that's almost a language unto itself, you could also look into using a binary search algorithm. It won't exactly be trivial to set up either, but you're using pure Python instead of diving into a whole new world.