I was going to use a lambda function that returns 'Purchase' for not null values and returns 'No Purchase' else. I am not be sure which one to use. If I use the first one it works. However, I can't understand why I have to use the first one instead of the second one.
df['is_purchase'] = df.click_day.apply(lambda x: 'Purchase' if pd.notnull(x) else 'No Purchase')
df['is_purchase'] = df.click_day.apply(lambda x: 'Purchase' if pd.notnull(x)==True else 'No Purchase')
Can someone please explain why the first one is true?
pd.notnull(x)==Trueis implied bypd.notnull(x), so the second is more wordy.