Skip to content

Instantly share code, notes, and snippets.

@cobanov
Created November 29, 2022 18:56
Show Gist options
  • Save cobanov/3270c1dd0fed03c51fecc894488328a0 to your computer and use it in GitHub Desktop.
Save cobanov/3270c1dd0fed03c51fecc894488328a0 to your computer and use it in GitHub Desktop.
Easily find location
from geopy.geocoders import Nominatim
from tqdm import tqdm
from geopy.extra.rate_limiter import RateLimiter
geolocator = Nominatim(user_agent="cobanov")
geocode = RateLimiter(geolocator.geocode, min_delay_seconds=1)
tqdm.pandas()
df['gcode'] = df['full_adress'].progress_apply(geocode)
df['point'] = df['gcode'].apply(lambda loc: tuple(loc.point) if loc else None)
df[['latitude', 'longitude', 'altitude']] = pd.DataFrame(df['point'].tolist(), index=df.index)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment