I have a dataframe (df1) where a column (Detail) contains a string in each row. I split each string of the column into a list using df1.Detail.str.split().
I have another column (Pass) that is set to 0 by default. I am trying to change the value of df1[Pass] to 1 if the list in df1[Detail] contains the word 'pass'. I am trying to do this on a row by row basis using iterrows().
When I run the following code, it properly displays rows that match my criteria and the corresponding index:
for index,row in df1.iterrows():
if 'pass' in i.Detail:
print i.Detail, index
However, when I try to update the row values in 'Pass' using the following code:
for index,row in df1.iterrows():
if 'pass' in i.Detail:
df1.loc[index,'Pass'] = 1
It ends up updating 98% of the row values in 'Pass' to 1, even if the row does not fit the criteria of containing the word 'pass' in 'Detail'. Does anybody know what could be causing this issue?