def getLatLon(x):
county = x['City']
state = x['State']
latlng = gmaps.geocode(f'{city}, {state}')[0]['geometry']['location']
try:
lat = latlng['lat']
lng = latlng['lng']
x['Latitude'] = lat
x['Longitude'] = lng
except KeyError:
x['Latitude'] = np.nan
x['Longitude'] = np.nan
return x
cities = cities.apply(getLatLon, axis=1)