I'm trying to concatenate some conditions but it's getting quite hard to solve it, here's the problem:
I have a df with 3 columns:
| Column1 | Column2 | Column3 |
|:-------:|:-------:|:-------:|
| A | x | |
| A | z | |
| B | p | |
| C | y | |
| C | w | |
So, what I'm trying to do is compare the value in column1 and column2 and if matches the condition add a "OK" to that row in column3 otherwise "KO" I'm trying something like this:
for letter in df['Column1']:
for letter1 in df['Column2']:
if((letter == 'A') and (letter1 == 'x')):
df['Column3'].append('OK')
if((letter == 'B') and (letter1 == 'p')):
df['Column3'].append('OK')
if((letter == 'C') and (letter1 == 'y')):
df['Column3'].append('OK')
else:
de['Column3'].append('KO')
The output should be like this:
| Column1 | Column2 | Column3 |
|:-------:|:-------:|:-------:|
| A | x | OK |
| A | z | KO |
| B | p | OK |
| C | y | OK |
| C | w | KO |
Thanks for the help!