title: Python pandas apply function if a column value is not NULL
body: <p>I have a dataframe (in Python 2.7, pandas 0.15.0):</p>
  
  <pre><code>df=
         A    B               C
  0    NaN   11             NaN
  1    two  NaN  ['foo', 'bar']
  2  three   33             NaN
  </code></pre>
  
  <p>I want to apply a simple function for rows that does not contain NULL values in a specific column. My function is as simple as possible:</p>
  
  <pre><code>def my_func(row):
      print row
  </code></pre>
  
  <p>And my apply code is the following:</p>
  
  <pre><code>df[['A','B']].apply(lambda x: my_func(x) if(pd.notnull(x[0])) else x, axis = 1)
  </code></pre>
  
  <p>It works perfectly. If I want to check column 'B' for NULL values the <code>pd.notnull()</code> works perfectly as well. But if I select column 'C' that contains list objects:</p>
  
  <pre><code>df[['A','C']].apply(lambda x: my_func(x) if(pd.notnull(x[1])) else x, axis = 1)
  </code></pre>
  
  <p>then I get the following error message: <code>ValueError: ('The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()', u'occurred at index 1')</code></p>
  
  <p>Does anybody know why <code>pd.notnull()</code> works only for integer and string columns but not for 'list columns'?</p>
  
  <p>And is there a nicer way to check for NULL values in column 'C' instead of this:</p>
  
  <pre><code>df[['A','C']].apply(lambda x: my_func(x) if(str(x[1]) != 'nan') else x, axis = 1)
  </code></pre>
  
  <p>Thank you!</p>