I have dataframe like this:
dict={'priorSaleYear':[2004, np.NaN],'lastSaleYear':[2008, 2009]}
df=pd.DataFrame(dict, index=[1,2])
I want to replace the np.nan with the lastSaleYear minor a number:
df['priorSaleYear']= df.apply (lambda row: (row['lastSaleYear'] - b) if row['priorSaleYear'] is np.nan else row['priorSaleYear'], axis=1)
But it seems like row['priorSaleYear'] is np.nan not work, can someone help me, thanks