<jupyter_start><jupyter_text>Create map from address data This is a simple script to assign geocoordinates to a list of locations and display the results on a map. 1. Source<jupyter_code># create an input dataframe

import pandas as pd


data = [['86 Quai Perrache, 69002 Lyon, France'],
        ['Rue du Premier Film, 69008 Lyon, France'],
        ["51 Rue de l'Université, 69007 Lyon, France"],
        ['38 Rue du Moulin À Vent, 69200 Lyon, France'],
        ['228 Avenue Berthelot, 69008 Lyon, France']] 
df = pd.DataFrame(data, columns = ['Location'])
df<jupyter_output><empty_output><jupyter_text>2. Code<jupyter_code># add geolocations to dataframe using Geopy

import geopy.geocoders
from geopy.geocoders import Nominatim
from geopy.extra.rate_limiter import RateLimiter

geopy.geocoders.options.default_user_agent = 'agent1'
geopy.geocoders.options.default_timeout = None
    
for x in df.Location:

    geolocator = Nominatim()
    location = geolocator.geocode(x)
    df.at[df[df['Location']==x].index[0], 'Longitude'] = location.longitude
    df.at[df[df['Location']==x].index[0], 'Latitude'] = location.latitude
    
df<jupyter_output><empty_output><jupyter_text>3. Results<jupyter_code># display results on a map

import folium

# using the first location as starting point

latitude = df.loc[0,'Latitude']
longitude = df.loc[0,'Longitude']

map_1 = folium.Map(location=[latitude, longitude], zoom_start=11) 

# add markers to map
for lat, lng, label in zip(df['Latitude'], df['Longitude'], df['Location']):
    label = folium.Popup(label, parse_html=True)
    folium.CircleMarker(
        [lat, lng],radius=5,
        popup=label,
        color='blue',
        fill=True,
        fill_color='#3186cc',
        fill_opacity=0.7,
        parse_html=False).add_to(map_1)

map_1<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12204507971412865, 'fraction_numerical': 0.029686641011544807, 'mean_word_length': 4.3372434017595305, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '611362', 'license': 'MIT', 'n_tokens_mistral': 675, 'n_tokens_neox': 634, 'n_words': 160, 'path': 'Mapping_tool.ipynb', 'repo_name': 'calabria18/audit', 'size': '1819'}