title: Using split to populate a column in Pandas dataframe
body: <p>I'm working with text data and I would simply like to populate a new column based on an existing column.</p>
  
  <p>Example: the column <code>sourceEncodedID</code> may have values like <code>a.b.c</code> and I'd like to extract only the second part of the string, <code>b</code>, if there's a second part available. Here are some example values:</p>
  
  <pre><code>sourceEncodedID    Branch    
  a.b.c               b    
  c.r.d               r    
  a                   a    
  p                   p
  </code></pre>
  
  <p>To achieve this, I have come up with the following code:</p>
  
  <pre><code>for i in range(0,20350):
      if len(str(artifacts.sourceEncodedID[i]).split('.')) &gt; 1:
          artifacts['branch'][i] = str(artifacts.sourceEncodedID[i]).split('.')[1]
      else:
          artifacts['branch'][i] = str(artifacts.sourceEncodedID[i])
  </code></pre>
  
  <p>There are only 20k rows in the dataframe and yet this piece of code take minutes to execute, before never finishing and rendering my browser unreponsive (I'm using <code>ipython notebook</code>). I would have thought this would run in a couple of seconds.</p>
  
  <p>Is there something obviously silly in this code that I'm unable to catch? How do I fix it?</p>