the question is quite similiar to this one: Fastest way to merge pandas dataframe on ranges
but I have several ranges to respect in my joining process.
I have a dataframe A:
ip_address server_port
0 13 2
1 5 2
2 20 4
3 11 4
.. ........
and a dataframe B:
lowerbound_ip_address upperbound_ip_address server_low server_high country
0 0 10 2 3 Australia
1 11 20 2 3 China
2 11 20 4 7 Belgium
How can i merge it that the rules are respected:
ip_address server_port country
0 13 2 China
1 5 2 Australia
2 20 4 Belgium
3 11 4 Belgium
My original idea is to write a loop for it, but is there a vectorized solution for it?