Maybe I'm slowly losing my mind but I've gotten iterrows() to work in the past but now I'm trying to it to edit row values using it and some rows do get changed while other don't.When iterrows works When iterrows doesn't work
The following worked (produced new columns called '1MM','3MM', and '5MM' and labeled correctly):
for index, row in merged.iterrows():
merged.at[index, '1MM'] = 'Yes' if row['Opportunity'] >=1 else 'No'
merged.at[index, '3MM'] = 'Yes' if row['Opportunity'] >=3 else 'No'
merged.at[index, '5MM'] = 'Yes' if row['Opportunity'] >=5 else 'No'
But this didn't work (some Client Firm names didn't get changed):
for i, row in ff.iterrows():
ff.at[i,'new'] = 'Raymond James' if re.search('Raymond James',row["Client Firm"]) else row['Client Firm']
ff.at[i,'new'] = 'Cetera' if re.search('Cetera',row['Client Firm']) else row['Client Firm']
ff.at[i,'new'] = 'LPL' if re.search('LPL',row['Client Firm']) else row['Client Firm']
ff.at[i,'new'] = 'Wells Fargo' if re.search('Wells Fargo',row['Client Firm']) else row['Client Firm']
The second dataframe looks something like this:
pd.DataFrame({'Client Firm':['Cetera Financial Services','LPL Financial Advisors','Raymond James Advisors'],'AUM':['50','30','40']})