I would like to identify doctors based on their title in a dataframe and create a new column to indicate if they are a doctor but I am struggling with my code.
doctorcriteria = ['Dr', 'dr']
def doctor(x):
if doctorcriteria in x:
return 'Doctor'
else:
return 'Not a doctor'
df['doctorcall'] = df.caller_name
df.doctorcall.fillna('Not a doctor', inplace=True)
df.doctorcall = df.doctorcall.apply(doctor)