patient_exp.loc[patient_exp['Location'].isnull(), 'Location'].apply(custom_gecode_func) code example Example: pandas isnull df.isnull().sum()