title: Geocoding distance between cordinates using python and google map API
body: <p>I am trying to calculate the distance between 2 cordinates. I have the below dataframe, I would like to calculate the driving distance between 2 cordinates. My code looks fine to me but still it doesn't work and it doesn't give me any error too. Any help is much appreicated.</p>
  <p>Data:</p>
  <pre><code>Origin_Latitude Origin_Longitude Dest_Latitude  Dest_Longitude
  34.0522342     -118.2436849     -10.9393        -37.06274211
  34.0522342     -118.2436849     -10.9392        -37.06276451
  34.0522342     -118.2436849     -10.9389        -37.0628786
  34.0522342     -118.2436849     -10.9415        -37.05734578
  
  </code></pre>
  <p>code:</p>
  <pre><code>API_key=&quot;API_KEY&quot;
  gmaps = googlemaps.Client(key=API_key)
  
  #pairwise
  def pairwise(iterable):
      a, b = tee(iterable)
      next(b, None)
      return zip(a, b)
  
  list = [0]
  
  for (i1, row1), (i2, row2) in pairwise(df.iterrows()):
      
      LatOrigin = row1['Origin_Latitude'] 
      LongOrigin = row1['Origin_Longitude']
      origins = (LatOrigin,LongOrigin)
  
     
      LatDest = row2['Dest_Latitude']   
      LongDest = row2['Dest_Longitude'] 
      destination = (LatDest,LongDest)
  
       
      result = gmaps.distance_matrix(origins, destination, mode='driving')['rows'][0]['elements'][0]['distance']['value']
        
      #appending result to list
      list.append(result)
  
  </code></pre>
  <p>Error: Just only once I got this error and the next time I tried to run the code it doesn't give me any error.</p>
  <pre><code>---------------------------------------------------------------------------
  KeyError                                  Traceback (most recent call last)
  &lt;ipython-input-51-e537000395b6&gt; in &lt;module&gt;
       21 
       22       #pass origin and destination variables to distance_matrix function# output in meters
  ---&gt; 23     result = gmaps.distance_matrix(origins, destination, mode='driving')['rows'][0]['elements'][0]['distance']['value']
       24 
       25       #append result to list
  
  KeyError: 'distance'
  </code></pre>