title: `try`/`except` block not working in pandas apply function
body: <p>I am trying to apply a function to <code>pandas</code> dataframe. My function has a <code>try/except</code> block to catch exceptions like <code>ZeroDivisionError</code> but it's failing.</p>
  
  <p>Data Frame have 100+ columns. And <strong>actual</strong> function is to be applied every row by selecting subset of columns</p>
  
  <p>Following is my code</p>
  
  <p>Function:</p>
  
  <pre><code>import pandas as pd
  import numpy as np
  
  def d(x):
      x0=22/7
      try:
          return x0/x
      except:
          return 0
  
  df=pd.DataFrame({'a':[0,2,3,4],'b':[0,3,4,5]})
  df
  
  Out[174]: 
     a  b
  0  0  0
  1  2  3
  2  3  4
  3  4  5
  </code></pre>
  
  <p>After applying Function as</p>
  
  <pre><code>df.apply(lambda x:d(x))
  
  Out[173]: 
            a         b
  0       inf       inf
  1  1.571429  1.047619
  2  1.047619  0.785714
  3  0.785714  0.628571
  </code></pre>
  
  <p>Expected <code>0</code> instead of <code>inf</code> at index <code>0</code></p>
  
  <pre><code>Out[173]: 
            a         b
  0  0.000000  0.000000
  1  1.571429  1.047619
  2  1.047619  0.785714
  3  0.785714  0.628571
  </code></pre>
  
  <p>Can anyone let me know what am I missing here. It's frustrating.... :@</p>