I'm a newbie to Python but attempting to call Google Distance Matrix API
This is how my data frame looks like
Loading data into data frame
data = pd.read_csv(input_filename, encoding ='utf8')
I just need some help looping the list.
Issue: It keeps on printing the entire list
#Column name in your input data
start_latitude_name = "Start Latitude"
start_longitude_name = "Start Longitude"
end_latitude_name = "End Latitude"
end_longitude_name = "End Longitude"
start_latitude_names = data[start_latitude_name].tolist()
end_latitude_names = data[end_latitude_name].tolist()
start_longitude_names = data[start_longitude_name].tolist()
end_longitude_names = data[end_longitude_name].tolist()
for start_latitude_name in start_latitude_names:
origins = start_latitude_name, start_longitude_name
destinations = end_latitude_name, end_longitude_name
mode = "walking"
# Set up your distance matrix url
distancematrix_url = "*Omitted unnecessary parts*origins={0}&destinations={1}&mode={2}&language=en-EN&key={3}".format(origins, destinations, mode, API_KEY)
print(distancematrix_url)
Current Output (From each loop)
# Omitted unnecessary info
origins=40.7614645,123.0,-73.9825913,456.0&destinations=40.65815,789.0,-73.98283,0.0
Expected Output (From each loop)
origins=40.7614645,-73.9825913&destinations=40.65815,-73.98283
I'm sure that i'm not looping it correctly, but i have tried the answers on several post and it didn't work work for me. I'm open to better alternatives of looping the data. Feel free to correct me.
Thanks!

startlatitudeandstart_latitude_names. Because otherwise your loop is unnecessary.