title: How to read attributes of an object column, using Python Pandas
body: <p>I have a dataframe where the <strong>'location'</strong> column contains an object:</p>
  
  <pre><code>import pandas as pd
  
  item1 = {
       'project': 'A',
       'location': {'country': 'united states', 'city': 'new york'},
       'raised_usd': 1.0}
  
  item2 =  {
      'project': 'B',
      'location': {'country': 'united kingdom', 'city': 'cambridge'},
      'raised_usd': 5.0}
  
  item3 =  {
      'project': 'C',
      'raised_usd': 10.0}
  
  data = [item1, item2, item3]
  
  df = pd.DataFrame(list(data))
  df
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/zRgIG.png" alt="enter image description here"></p>
  
  <p>I'd like to create an extra column, <strong>'project_country'</strong>, which contains just the country information, if available. I've tried the following:</p>
  
  <pre><code>def get_country(location):
      try:
          return location['country']
      except Exception:
          return 'n/a'
  
  df['project_country'] = get_country(df['location'])
  df
  </code></pre>
  
  <p>But this doesn't work:
  <img src="https://i.stack.imgur.com/cl9CR.png" alt="enter image description here"></p>
  
  <p>How should I go about importing this field?</p>