<jupyter_start><jupyter_text>2. Adding Lattitude and Longitude<jupyter_code>import pandas as pd
import numpy as np
import geocoder
df = pd.read_csv('toronto.csv')
df
df.describe()
def latlong(postal_code):
    lati_long_coords = None
    while(lati_long_coords is None):
        g = geocoder.arcgis('{}, Toronto, Ontario'.format(postal_code))
        lati_long_coords = g.latlng
    return lati_long_coords
    
latlong('M1B')[0]
df
lat= []
long = []
for i in df['Postal Code'].values:
    lat.append(latlong(i)[0])
    long.append(latlong(i)[1])
df['Latitude'] = lat
df['Longitude'] = long
df
df.to_csv('toronto_latlong.csv', index = False)<jupyter_output><empty_output>
StarcoderdataJupyterStructuredCleanDedup