Geocoding "ValueError: Columns must be same length as key"

Viewed 101

Badly need help on getting coordinates

I was following the steps in https://towardsdatascience.com/geocode-with-python-161ec1e62b89 https://hub-binder.mybinder.ovh/user/shakasom-geocoding-ovfmqckk/tree

from geopy.extra.rate_limiter import RateLimiter

# 1 - conveneint function to delay between geocoding calls
geocode = RateLimiter(locator.geocode, min_delay_seconds=1)
# 2- - create location column
df['location'] = df['ADDRESS'].apply(geocode)
# 3 - create longitude, laatitude and altitude from location column (returns tuple)
df['point'] = df['location'].apply(lambda loc: tuple(loc.point) if loc else None)
# 4 - split point column into latitude, longitude and altitude columns
df[['latitude', 'longitude', 'altitude']] = pd.DataFrame(df['point'].tolist(), index=df.index)

and the error "ValueError: Columns must be same length as key" pops out. Any workaround for this? TIA

0 Answers
Related