I'm currently trying to pull the latitude and longitude values from a series of addresses that are currently stored in a pandas dataframe. I have the following code currently:
import pandas as pd
from googlemaps import Client as GoogleMaps
GoogleAPIkey = "myAPIkey"
gmaps = GoogleMaps(GoogleAPIkey)
df = pd.read_csv("addresslist")
df output is as follows:
|Location |
0|Robert Pitt Drive, Spring Valley, NY|
1|Bryant Avenue, Harrison, NY |
Ideally I'd like to have the following output:
|Location | Lat | Lon |
0|Robert Pitt Drive, Spring Valley, NY| | |
1|Bryant Avenue, Harrison, NY | | |
I'm using the following code to create a new column in the df:
df["geocode_result"] = gmaps.geocode(df["Location"])
However, I get a ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
Do I need to convert my string series to another format to get the right value?
Thanks