Fastest way to merge pandas dataframe on ranges

Viewed 5403

I have a dataframe A

    ip_address
0   13
1   5
2   20
3   11
.. ........

and another dataframe B

    lowerbound_ip_address   upperbound_ip_address           country
0    0                       10                             Australia
1    11                      20                             China

based on this I need to add a column in A such that

ip_address  country
13          China
5           Australia

I have an idea that I should write define a function and then call map on each row of A. But how would I search through each row of B for this. Is there a better way to do this.

3 Answers
Related