title: TypeError: string indices must be integers in Pandas
body: <p>I have a dataFrame with 1 column of 'JSON' or dictionary type data in strings. To convert it into Python Dictionary, I came up with following code from Stackoverflow</p>
  <pre class="lang-py prettyprint-override"><code>class Iden():
    def __getitem__(name, index):
      return index
  
  df['genres'].map(lambda a: eval(str(a), {}, Iden()))
  </code></pre>
  <p>which converts it into dictionary, which I confirmed using following code,</p>
  <pre class="lang-py prettyprint-override"><code>df['genres'].map(lambda a: eval(str(a), {}, Iden())).map(lambda a: type(a[0]))
  </code></pre>
  <p>and my output was</p>
  <pre><code>0       &lt;class 'dict'&gt;
  1       &lt;class 'dict'&gt;
  2       &lt;class 'dict'&gt;
  3       &lt;class 'dict'&gt;
  4       &lt;class 'dict'&gt;
               ...  
  </code></pre>
  <p>Now, single variable of <code>genres</code> is as follows</p>
  <pre><code>&quot;[{'id': 35, 'name': 'Comedy'}]&quot;
  </code></pre>
  <p>I want to extract the <code>name</code> from this and my code is</p>
  <pre class="lang-py prettyprint-override"><code>df['genres'].map(lambda a: eval(str(a), {}, Iden())).map(lambda a: a[0]['name'])
  </code></pre>
  <p>but it is giving error</p>
  <pre><code>--------------------------------------------------------------------------
  TypeError                                 Traceback (most recent call last)
  &lt;ipython-input-109-3da37181d7d9&gt; in &lt;module&gt;
  ----&gt; 1 df['genres'].map(lambda a: eval(str(a), {}, Iden())).map(lambda a: a[0]['name'])
  
  C:\Anaconda\envs\myenv\lib\site-packages\pandas\core\series.py in map(self, arg, na_action)
     3628         dtype: object
     3629         &quot;&quot;&quot;
  -&gt; 3630         new_values = super()._map_values(arg, na_action=na_action)
     3631         return self._constructor(new_values, index=self.index).__finalize__(self)
     3632 
  
  C:\Anaconda\envs\myenv\lib\site-packages\pandas\core\base.py in _map_values(self, mapper, na_action)
     1143 
     1144         # mapper is a function
  -&gt; 1145         new_values = map_f(values, mapper)
     1146 
     1147         return new_values
  
  pandas\_libs\lib.pyx in pandas._libs.lib.map_infer()
  
  &lt;ipython-input-109-3da37181d7d9&gt; in &lt;lambda&gt;(a)
  ----&gt; 1 df['genres'].map(lambda a: eval(str(a), {}, Iden())).map(lambda a: a[0]['name'])
  
  TypeError: string indices must be integers
  </code></pre>
  <p>First 5 rows of <code>genres</code> is</p>
  <pre><code>0                       [{'id': 35, 'name': 'Comedy'}]
  1    [{'id': 35, 'name': 'Comedy'}, {'id': 18, 'nam...
  2                        [{'id': 18, 'name': 'Drama'}]
  3    [{'id': 53, 'name': 'Thriller'}, {'id': 18, 'n...
  4    [{'id': 28, 'name': 'Action'}, {'id': 53, 'nam...
  </code></pre>
  <p>What can be potential reason and potential fix for this error?</p>