问题描述
我有一个大约 750,000 行的数据框。我在 2 个不同的列中有经度和纬度。我想使用 geopy 来获取每一行的邮政编码。我当前的代码持续运行了一个小时,到目前为止还看不到尽头。有没有办法更快地做到这一点?
def get_zipcode(df,geolocator,latitude_column,longitude_column):
location = geolocator.reverse((df[latitude_column],df[longitude_column]))
return location.raw['address']['postcode']
geolocator = geopy.Nominatim(user_agent='dsir group project')
from geopy.extra.rate_limiter import RateLimiter
geocode = RateLimiter(geolocator.geocode,min_delay_seconds=1)
df.apply(get_zipcode,axis=1,geolocator=geolocator,lat_column='latitude',long_column='longitude')
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)