I am trying to add a new column "profile_type" to a dataframe "df_new" which contains the string "Decision Maker" if the "job_title" has any one of the following words: (Head or VP or COO or CEO or CMO or CLO or Chief or Partner or Founder or Owner or CIO or CTO or President or Leaders),
"Key Influencer" if the "job_title" has any one of the following words: (Senior or Consultant or Manager or Learning or Training or Talent or HR or Human Resources or Consultant or L&D or Lead), and
"Influencer" for all other fields in "job_title".
For example, if the 'job_title' includes a row "Learning and Development Specialist", the code has to pull out just the word 'Learning' and segregate it as 'Key Influencer' under 'profile_type'.
The below code worked for me.
import re
s1 = pd.Series(df['job_title'])
condition1 = s1.str.contains('Director|Head|VP|COO|CEO...', flags=re.IGNORECASE, regex=True)
condition2 = s1.str.contains('Senior|Consultant|Manager|Learning...', flags=re.IGNORECASE, regex=True)
df_new['profile_type'] = np.where(condition1 == True, 'Decision Maker',
(np.where(condition2 == True, 'Key Influencer', 'Influencer')))