title: How do I make my error handling better?
body: <p>I'm pulling data that needs to have a column of ID values in order to match it with another data set. This ID number is located within a campaign name in the data set I am pulling in a column named 'Campaign' in a DataFrame. When I try and extract the ID number from 'Campaign' this list is shorter than the total entries of the DataFrame. I think that my error handling is to blame. An entry in 'Campaign' generally follows this format: </p>
  
  <pre><code>'CompanyAbbreviation_CampaignName_AccountNumber_ChannelNumber' 
  </code></pre>
  
  <p>(it is this Channel number that I am trying to extract), however, some entries will be missing AccountNumber, ChannelNumber while other will have a full entry plus '_deleted'.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>ID = []
  campaigns = frame['Campaign']
  for cam in campaigns:
      try:
          blocks = re.split('_',cam)
          for block in blocks:
              if len(block) == 6 and block.isdigit() or 5 and block.isdigit():
                  ID.append(block)
      except ValueError:
          ID.append(000000)
  ID = pd.Series(ID)
  #frame.index = ID
  #frame['Channel_ID'] = frame.index
  return frame, ID
  </code></pre>
  
  <p>Edit: Screenshot of some data
  <a href="http://prntscr.com/8jck72" rel="nofollow">http://prntscr.com/8jck72</a></p>