title: How to put the outcome of a loop as values of a Dataframe column?
body: <p>I am running a code with the python RegEx module. In particular, I want to extract hashtags from the text of some tweets. I have a Dataframe containing various columns of which 'text' is one.
  My code is following:</p>
  <pre><code>`import re
  spilthash = re.compile(r&quot;#(\w+)&quot;)
  
  def split_tags(s):
      return spilthash.findall(s)
  
  for t in df['text']:
      tags = split_tags(t)
      print(tags)'
  </code></pre>
  <p>The code runs perfectly and outputs the hashtags of each row as a list. For example, the first three rows' output is the following:['Sozialismus', 'Mauerbau']['Covid_19', 'Testpflicht', 'coronapandemie', 'Impfpflicht'][]</p>
  <p>I want to amend my code to save this output as a column in the original Dataframe. That is, I should get: df['Hashtags'] = [{'Sozialismus', 'Mauerbau'}, {'Covid_19'....}, ......]</p>
  <p>I tried different codes with append but it simply puts the entire outcome as one list, where one can't differentiate between the rows. For, example, when I tried the following:</p>
  <pre><code>import re
  spilthash = re.compile(r&quot;#(\w+)&quot;)
  
  def split_tags(s):
      return spilthash.findall(s)
  
  hashtags = []
  for t in df['text']:
      tags = split_tags(t)
     
      for x in tags:
          hashtags.append(x)
  </code></pre>
  <p>Output: ['Sozialismus','Mauerbau','Covid_19','Testpflicht',.......]</p>
  <p>I would appreciate any help with the code.</p>