I can't figure how to iterate a dataframe row by row and update cell values based on conditions from other cells. If a partial string is found in one cell and if simultaneously another cell has a specific value then I should add a specific value to a cell
Have tried also:
for i, row in df3.iterrows():
codmarime = ''
if df3['20755' in df3['ITEM CODE'][i]] and df3['24' in df3['TG'][i]]:
codmarime= '002'
df3['SKU'][i] = '20'+str(df3['ITEM CODE'][i])+str(df3['COLOR CODE'][i])+codmarime
for i, row in df3.iterrows():
codmarime = ''
if df3['ITEM CODE'].str.contains("20755") and df3['TG'].str.contains("24"):
codmarime= '002'
df3['SKU'][i] = '20'+str(df3['ITEM CODE'][i])+str(df3['COLOR CODE'][i])+codmarime
elif df3['ITEM CODE'].str.contains("20755") and df3['TG'].str.contains("25"):
codmarime= '003'
df3['SKU'][i] = '20'+str(df3['ITEM CODE'][i])+str(df3['COLOR CODE'][i])+codmarime
Output
> ValueError Traceback (most recent call last)
>
> ----> 6 if df3['ITEM CODE'].str.contains("20755") and df3['TG'].str.contains("24"):