Current outcome:
*Email* *Organization*
[email protected] /Org: First
[email protected] /Org: First
[email protected] /Org: First
Desired outcome:
*Email* *Organization*
[email protected] /Org: First
[email protected] /Org: Second
[email protected] /Org: First
Condition:
If a row in column('Email') contains the string('second'):
Replace the string in the same row, under column('Organization') with the string('/Org: Second')
Any way of doing this? Currently working with pandas to amend this csv. I used the following to segregate one set of domains from the other:
df = pd.read_csv("file.csv", sep=r'\s*,\s*', engine='python')
second_domains = df.loc[df['Email'].str.contains('second')]
But I don't know what else to do from here.
Thank you all very much!
CodePudding user response:
Try using loc
assignment:
df.loc[df['Email'].str.contains('second'), 'Organization'] = '/Org: Second'