title: Exception Handling in Pandas .apply() function
body: <p>If I have a DataFrame:</p>
  
  <pre><code>myDF = DataFrame(data=[[11,11],[22,'2A'],[33,33]], columns = ['A','B'])
  </code></pre>
  
  <p>Gives the following dataframe (Starting out on stackoverflow and don't have enough reputation for an image of the DataFrame)</p>
  
  <pre><code>   | A  | B  |
  
  0  | 11 | 11 |
  
  1  | 22 | 2A |
  
  2  | 33 | 33 |
  </code></pre>
  
  <p>If i want to convert column B to int values and drop values that can't be converted I have to do:</p>
  
  <pre><code>def convertToInt(cell):
      try:
          return int(cell)
      except:
          return None
  myDF['B'] = myDF['B'].apply(convertToInt)
  </code></pre>
  
  <p>If I only do:</p>
  
  <blockquote>
    <p>myDF['B'].apply(int)</p>
  </blockquote>
  
  <p>the error obviously is:</p>
  
  <blockquote>
    <p>C:\WinPython-32bit-2.7.5.3\python-2.7.5\lib\site-packages\pandas\lib.pyd
    in pandas.lib.map_infer (pandas\lib.c:42840)()</p>
    
    <p>ValueError: invalid literal for int() with base 10: '2A'</p>
  </blockquote>
  
  <p>Is there a way to add exception handling to myDF['B'].apply()</p>
  
  <p>Thank you in advance!</p>