Reputation: 149
I have a pandas data frame as below, here I when I find "Log file validation"
I need to make its corresponding SITT
column as "YES"
and if "Sequence Validation"
then "NO"
and it varies for each and every row. I am looping through the contents in "Checklist"
column and how do I alter the corresponding value in SITT
column.
Checklist SITT
0 Log file validation NaN
1 Sequence Validation NaN
2 Recreating failed constraints NaN
3 Synonyms and grants Validation NaN
4 Creating Table structures for excluded tables NaN
I tried below different method and more different ways, nothing seems to give me expected result.
sheet_read.loc[(sheet_read['Checklist'] == 'Log file validation') & (sheet_read['SITT'] == 'NaN'), 'SITW'] = 'Mismatch'
Any help on this please.
Upvotes: 0
Views: 115
Reputation: 8940
df['SITT'] = df['SITT'].astype(str)
for i, e in enumerate(df['Checklist']):
if e=='Log file validation':
df.at[i,'SITT']='yes'
if e=='Sequence Validation':
df.at[i,'SITT']='no'
df['SITT'] = df['SITT'].replace('nan', np.nan)
Upvotes: 1