title: Pandas Lambda Function with Nan Support
body: <p>I am trying to write a lambda function in Pandas that checks to see if Col1 is a Nan and if so, uses another column's data.  I have having trouble getting code (below) to compile/execute correctly. </p>
  
  <pre><code>import pandas as pd
  import numpy as np
  df=pd.DataFrame({ 'Col1' : [1,2,3,np.NaN], 'Col2': [7, 8, 9, 10]})  
  df2=df.apply(lambda x: x['Col2'] if x['Col1'].isnull() else x['Col1'], axis=1)
  </code></pre>
  
  <p>Does anyone have any good idea on how to write a solution like this with a lambda function or have I exceeded the abilities of lambda?  If not, do you have another solution?  Thanks.</p>