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 c
You need to use np.nan()
#import numpy as np df2=df.apply(lambda x: 2 if np.isnan(x['Col1']) else 1, axis=1) df2 Out[1307]: 0 1 1 1 2 1 3 2 dtype: int64