title: KeyError when creating new column in python pandas
body: <p>I am trying to create a new column in python pandas, and I keep getting an (unsteady) reoccurring KeyError. The section of the script is very straightforward so I am not sure what could be causing the error since none of the columns in the dataset have the same name.</p>
  
  <p>My goal is to created a new column and append it to the dataframe that contains the new translations of the content of the column ticket_contents.
  Here is a sample of the data;</p>
  
  <pre><code>25483   0   outstanding 0   Los-Angeles e-payment   delayed Ticket  1/7/19 7:54
  39363   0   outstanding 0   Los-Angeles e-payment   delayed Ticket  1/7/19 7:54
  83584   0   outstanding 6   Los-Angeles e-payment   delayed Ticket  1/7/19 7:54
  34537   0   outstanding 7   Los-Angeles e-payment   lost    Ticket  1/7/19 7:53
  
  
  
  colnames = ['id', 'ln_id', 'status', 
  'number_outstanding', 'country', 'subject', 'ticket_contents', 'subtopic', 
  'date']
  test_data = pandas.read_csv(test_data, names = colnames, encoding 
  = 'utf-8')
  test_data = pandas.DataFrame(test_data)
  
  translated_description = []
  
  from_lang = 'tl'
  to_lang = 'en-us'
  
  def test_translation(contents):
      translator = Translator(from_lang = from_lang, to_lang = to_lang)
      translation = translator.translate(contents)
      translated_description.append(translation)
      #print(translated_description)
  
  
  for contents, row in test_data.iterrows():
      contents = test_data.ticket_contents.iloc[contents -1]
      test_translation(contents)
  
  test_data['translated_descriptions'].copy = translated_description
  </code></pre>
  
  <p>Here is the error output:</p>
  
  <pre><code>KeyError Traceback (most recent call last)
  &lt;ipython-input-70-55e39cf5e328&gt; in &lt;module&gt;()
       16     test_translation(contents)
       17 
  ---&gt; 18 test_data['translated_descriptions'].copy = translated_description
       19 
  
  /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pandas/core/frame.pyc in __getitem__(self, key)
     1962             return self._getitem_multilevel(key)
     1963         else:
  -&gt; 1964             return self._getitem_column(key)
     1965 
     1966     def _getitem_column(self, key):
  
  /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pandas/core/frame.pyc in _getitem_column(self, key)
     1969         # get column
     1970         if self.columns.is_unique:
  -&gt; 1971             return self._get_item_cache(key)
     1972 
     1973         # duplicate columns &amp; possible reduce dimensionality
  
  /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pandas/core/generic.pyc in _get_item_cache(self, item)
     1643         res = cache.get(item)
     1644         if res is None:
  -&gt; 1645             values = self._data.get(item)
     1646             res = self._box_item_values(item, values)
     1647             cache[item] = res
  
  /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pandas/core/internals.pyc in get(self, item, fastpath)
     3588 
     3589             if not isnull(item):
  -&gt; 3590                 loc = self.items.get_loc(item)
     3591             else:
     3592                 indexer = np.arange(len(self.items))[isnull(self.items)]
  
  /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pandas/core/indexes/base.pyc in get_loc(self, key, method, tolerance)
     2442                 return self._engine.get_loc(key)
     2443             except KeyError:
  -&gt; 2444                 return self._engine.get_loc(self._maybe_cast_indexer(key))
     2445 
     2446         indexer = self.get_indexer([key], method=method, tolerance=tolerance)
  
  pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc (pandas/_libs/index.c:5280)()
  
  pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc (pandas/_libs/index.c:5126)()
  
  pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item (pandas/_libs/hashtable.c:20523)()
  
  pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item (pandas/_libs/hashtable.c:20477)()
  
  KeyError: u'translated_descriptions'
  </code></pre>