I would like a function where if the area column has missing values (like NULL in SQL) the result is 'A' in the target 'wanted' variable.
I'm confused about use of None, isnull(), np.nan concepts in Python
raw_data = {'area': ['S','W',np.nan,np.nan], 'wanted': [np.nan,np.nan,'A','A']}
df = pd.DataFrame(raw_data, columns = ['area','wanted'])
df
def my_func(x):
if (x) is None:
return 'A'
else:
return np.nan
df['wanted2'] = df['area'].apply(my_func)
df