How to get latitude and longitude using addresses and the GoogleMaps API

My data set comes from http://book.flowingdata.com/ch08/geocode/costcos-limited.csv

import googlemaps
import pandas as pd

#get a key here https://console.cloud.google.com/google/maps-apis/start
g_api_key = 'YOUR API KEY HERE'

#register your key 
gmaps = googlemaps.Client(key=g_api_key)


#import the csv file from http://book.flowingdata.com/ch08/geocode/costcos-limited.csv
#only 5 columns should exist, if you get an error saying more do then select the next 5 columns and delete them
df = pd.read_csv('datasources/costcos-limited.csv', skiprows = 0)

#create two new columns for the lat and long in your DataFrame
df["latitude"] = ""
df["longitude"] = ""

#iterate over your dataframe
for index, row in df.iterrows():
    #pass in an address, in my case I am passing Address, City, State
    #the more accurate you pass in the more likely your results is accurate
    location = gmaps.geocode(row[1] + ", " + row[2] + ", " + row[3])
    
    #write the new values to your DataFrame
    df.loc[index, 'latitude'] = location[0]['geometry']['location']['lat']
    df.loc[index, 'longitude'] = location[0]['geometry']['location']['lng']
    
#create a new dataframe from your list of lists
#save the dataframe to back to your csv
df.to_csv("datasources/costcolocations.csv", sep=',',index=False)
print(df)