Just encountered this problem myself and found a solution, imperfect, but works. As noted above, none of these 3 answers are addressing OP's question. Here's an example of my problem which I feel is the same.
# fill null values of one column with that of another
f = lambda row: row['A'] if (row['B'].isnull()) else row['B']
df['B'] = df.apply(f, axis=1)
>>> AttributeError: 'str' object has no attribute 'isnull'
Because the value within a cell of a dataframe is just a primative datatype, you can't use any of pandas built-in methods. So this is what I did.
f = lambda row: row['A'] if (str(row['B'])=='nan') else row['B']
This actually the only thing I could get to work!