module data.geocoding#

Short summary#

module actuariat_python.data.geocoding

Various function to download data about French elections.

source on GitHub

Functions#

function

truncated documentation

geocode

geocode addresses

Documentation#

Various function to download data about French elections.

source on GitHub

actuariat_python.data.geocoding.geocode(df, col_city='city', col_place='place', col_zip='zip', col_address='address', col_latitude='latitude', col_longitude='longitude', col_full='full_address', col_geo='geo_address', save_every=None, every=100, exc=True, fLOG=None, coders=('Nominatim',), country=None, **options)#

geocode addresses

Paramètres:
  • df – dataframe

  • col_city – city

  • col_place – place

  • col_zip – zip

  • col_address – address

  • col_latitude – latitude

  • col_longitude – longitude

  • col_full – full address (send to the geocoder)

  • col_geo – address returned by the geocoder

  • save_every – to make regular dump

  • every – save every every

  • exc – raises exception or warning (False)

  • options – options for read_csv to do regular dumps

  • coders – list of coders to try

  • country – append the country before geocoding

  • fLOG – logging function

Renvoie:

modified dataframe

If save_every_100 is filled, the function will save the dataframe every 100 geocoded addresses. If the file is already present, it will be loaded the function will continue geocoding where it stopped.

The function does not work well if it is called from multiple threads or processes. It might slow on purpose. Example for coder:

["Nominatim", ("bing", <bing_key>)]

The function tries the first one and then the second one. The function also caches the results. If the same address appears twice, the geocoder will not be called a second time, it will reuse the cache results unless there was no answer on the first call.

source on GitHub