title: TypeError: string indices must be integers (working with pandas Dataframe)
body: <p>Humbly asking again for the community's help.</p>
  <p>I have a task in Data Analysis, to research the connections between different columns of the dataset given. For that sake I have to edit the columns I want to work with. The column I need contains data, which looks like a list of dictionaries, but it's actually a string. So I have to edit it to take 'name' values from those former &quot;dictionaries&quot;.</p>
  <p>The code below represents my magical rituals to take &quot;name&quot; values from that string, to save them in another column as a string with only those &quot;name&quot; values collected in a list, after what I would apply that function to a whole column and group it by unique combinations of those strings with &quot;name&quot; values. <em>(Maximum-task was to separate those &quot;name&quot; values for several additional columns, to sort them later by all these columns; but the problem appeared, that a huge string in source column (df['specializations']) can contain a number of &quot;dictionaries&quot;, so I can't know exactly, how many additional columns to create for them; so I gave up on that idea.)</em></p>
  <p>Typical string with pseudo-list of dictionaries looks like that (the number of those &quot;dictionaries&quot; varies):</p>
  <p><code>[{'id': '1.172', 'name': 'Beginner', 'profarea_id': '1', 'profarea_name': 'IT'}, {'id': '1.117', 'name': 'Testing', 'profarea_id': '1', 'profarea_name': 'IT'}, {'id': '15.93', 'name': 'IT', 'profarea_id': '15', 'profarea_name': 'Beginner'}]</code></p>
  <pre><code>import re
  
  def get_names_values(df):
      for a in df['specializations']:
          for r in ((&quot;\'&quot;, &quot;\&quot;&quot;), (&quot;[&quot;, &quot;&quot;), (&quot;]&quot;, &quot;&quot;), (&quot;}&quot;, &quot;&quot;)):
              a = a.replace(*r)
          a = re.split(&quot;{&quot;, a)
          m = 0
          while m &lt; len(a):
              if a[m] in ('', ': ', ', '):
                  del a[m]
              m += 1
          a = &quot;&quot;.join(a)
          a = re.split(&quot;\&quot;&quot;, a)
          n = 0
          while n &lt; len(a):
              if a[n] in ('', ': ', ', '):
                  del a[n]
              n += 1
          nameslist = []
          for num in range(len(a)):
              if a[num] == 'name':
                  nameslist.append(a[num+1])
          return str(nameslist)
  
  
  df['specializations_names'] = df['specializations'].fillna('{}').apply(get_names_values)
  df['specializations_names']
  </code></pre>
  <p>The problem arouses with <code>for a in df['specializations']:</code>, as it raises
  <code>TypeError: string indices must be integers</code>. I checked that cycle separately, like (print(a)), and it gave me a proper result; I tried it also via:</p>
  <pre><code>for k in range(len(df)):
    a = df['specializations'][k]
  </code></pre>
  <p>and again, separately it worked as I needed, but inside my function it raises TypeError.
  I feel like I'm going to give up on ['specialization'] column and try researching some others; but still I'm curious what's wrong here and how to solve this problem.</p>
  <p>Huge thanks to all those who will try to advise, in advance.</p>