I have around 3500 JSON records with shapes like this:
{'text_analysis_raw_response': [{'entity_group': 'PER', 'score': 0.9537515640258789, 'word': 'God Almighty', 'start': 17, 'end': 29}, {'entity_group': 'ORG', 'score': 0.7446494102478027, 'word': 'Cali', 'start': 51, 'end': 55}, {'entity_group': 'LOC', 'score': 0.43644213676452637, 'word': 'te', 'start': 58, 'end': 60}, {'entity_group': 'LOC', 'score': 0.9999852180480957, 'word': 'Shaqraq', 'start': 128, 'end': 135}, {'entity_group': 'LOC', 'score': 0.9999912977218628, 'word': 'Al-Muqdadiya', 'start': 157, 'end': 169}, {'entity_group': 'PER', 'score': 0.9992551207542419, 'word': 'God', 'start': 346, 'end': 349}], 'text_locations_names': ['Shaqraq', 'Al-Muqdadiya'], 'et_sec': 7}
I want to store the text_locations_names in a new column in my DataFrame.
Using the line code:
data.at[index, 'new_locations_names'] = result['text_locations_names']
It gives me the following error:
TypeError                                 Traceback (most recent call last)
TypeError: float() argument must be a string or a number, not 'list'
The above exception was the direct cause of the following exception:
ValueError                                Traceback (most recent call last)
<ipython-input-7-4ed103f87b65> in <module>
      2     result = extract_location_with_xlm_roberta(row['translated_title'])
      3     print(result)
----> 4     data.at[index, 'new_locations_names'] = result['text_locations_names']
      5 #     break
C:\ProgramData\Anaconda3\lib\site-packages\pandas\core\indexing.py in __setitem__(self, key, value)
   2089             return
   2090 
-> 2091         return super().__setitem__(key, value)
   2092 
   2093 
C:\ProgramData\Anaconda3\lib\site-packages\pandas\core\indexing.py in __setitem__(self, key, value)
   2040             raise ValueError("Not enough indexers for scalar access (setting)!")
   2041 
-> 2042         self.obj._set_value(*key, value=value, takeable=self._takeable)
   2043 
   2044 
C:\ProgramData\Anaconda3\lib\site-packages\pandas\core\frame.py in _set_value(self, index, col, value, takeable)
   3145             validate_numeric_casting(series.dtype, value)
   3146 
-> 3147             series._values[loc] = value
   3148             # Note: trying to use series._set_value breaks tests in
   3149             #  tests.frame.indexing.test_indexing and tests.indexing.test_partial
ValueError: setting an array element with a sequence.
Any thoughts on solving it?

