Created
November 29, 2022 18:56
-
-
Save cobanov/3270c1dd0fed03c51fecc894488328a0 to your computer and use it in GitHub Desktop.
Easily find location
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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