I am trying to loop through a pandas dataframe and every time that a specific string appears, it will set the value for the cell on the same row but 2 columns previous, to the value of the cell one row before the specific text. I have attached a visual explanation of what I am trying to do if that does not make sense.
Code:
for index, row in df.iterrows():
if row[3] == 'National Account Job Coordinator':
row[1] = df.iloc[index-1, 3]
else:
continue
The code will print out the correct values, but does not set the dataframe values... Any ideas? Thanks