title: Apply postcode API call to each row in dataframe
body: <p>In the below code block, I have a dataframe, <code>geo</code>, which I want to iterate over to get the easting, northing, longitude and latitude for each UK postcode in <code>geo</code>.  I've written a function to call the API and another to return the four variables.</p>
  <p>I've tested the <code>get_data</code> call with a postcode to prove it works (this is a public API anyone can use):</p>
  <pre><code>import requests 
  import pandas as pd
  
  geo = spark.table('property_address').toPandas()
  
  
  def call_api(url: str) -&gt; dict:
    postcode_response =requests.get(url)
    return postcode_response.json()
  
  def get_data(postcode):
  
    url = f&quot;http://api.getthedata.com/postcode/{postcode}&quot;
    
    req = r.get(url)
    
  
    results = req.json()['data']
    easting = results['easting']
    northing = results['northing']
    latitude = results['latitude']
    longitude = results ['longitude']
    
    return easting ,northing,latitude, longitude
  
  get_data('SW1A 1AA')
  </code></pre>
  <p>which returns:</p>
  <pre><code>Out[108]: (529090, 179645, '51.501009', '-0.141588')
  </code></pre>
  <p>Want I want to do is run that for each row in <code>geo</code> and return it as a dataset.  My research has led me to <code>apply</code>, and I've based my attempt on <a href="https://www.codingforentrepreneurs.com/blog/api-calls-pandas-dataframe-pd-apply" rel="nofollow noreferrer">this guide</a>.</p>
  <p>I'm trying to pass a column called <code>property_postcode</code> in <code>geo</code> and iterate each row to return the values, here's my attempt:</p>
  <pre><code>def get_columns(row):
    column_name = 'property_postcode'
    api_param = row[column_name]
    easting,northing,latitude,longitude = get_data(api_param)
    row['east'] = easting
    row['north'] = northing
    row['lat'] = latitude
    row['long'] = longitude
    return row
  
  geo= geo.apply(get_columns, axis=1)
  
  display(geo)
  </code></pre>
  <p>The error I get is</p>
  <pre><code>`JSONDecodeError: Expecting value: line 1 column 1 (char 0)`
  </code></pre>
  <p>Doesn't tell me a huge amount.  Looking for assistance\pointers.</p>