I'm trying to run this code:
for x in range(len(df10)):
    try:
        time.sleep(1) #to add delay in case of large DFs
        geocode_result = gmaps.geocode(df10['Address'][x])
        df10['lat'][x] = geocode_result[0]['geometry']['location'] ['lat']
        df10['long'][x] = geocode_result[0]['geometry']['location']['lng']
    except IndexError:
        print("Address was wrong...")
    except Exception as e:
        print("Unexpected error occurred.", e )
I would like the for loop to iterate over a list of addresses, which is now stored in the column of a pandas dataframe called df10['Address'], then apply Google geocoding service to extract the longitude and latitude for each row and save these as columns of the original dataframe.
When I try to do this, I get the following error:
SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame
I understand this is because I'm trying to overwrite on the original dataframe, but I'm really struggling to find an alternative code that works.
Hopefully someone can help!
 
     
    