I am trying to define a function that replaces the value in 'BsmtFinType1' based on the value of the column 'MSSubClass'. However, I want it to first check to make sure the 'value to be replaced' is NaN. If it has a value, it does not replace it. I am not entirely sure why my sample won't work. After running it, none of the values update. If I remove the first 'If' Statement, it runs and replaces values just fine. Any ideas?
# Fill Basement Finishes
def fills_na(x):
if x['BsmtFinType1'] != np.NaN:
return x['BsmtFinType1']
elif x['MSSubClass'] < 60:
return 'Unf'
else:
return 'GLQ'
all_data['BsmtFinType1'] = all_data.apply(lambda x: bsmt_fin(x), axis=1)