0

I would like to do some reverse geocoding on my dataframe using geopy. However, I have 3000 obs and it raises the GeocoderServiceError: HTTP Error 429: Too Many Requests.

I would then like to run the code using the apply method together with a time.sleep in order to send a request every 0.5 millisecond. Anyone can help me with this?

here is my code:

home['coords'] = home['Latitude'].map(str) + ", " + home['Longitude'].map(str)
home['address'] = home['coords'].apply(geolocator.reverse)

Thank you, Fede

federico zampu
  • 99
  • 1
  • 10

1 Answers1

0

You'd want to write your own function and then apply it

def get_address(x):
    ''' apply reverse geocode to geo-coordinates, 
    but sleep half millisecond in between requests'''
    time.sleep(0.0005)
    return geolocator.reverse

home['address'] = home['coords'].apply(get_address)