I have a DataFrame with two columns, where I want to create a third column based on the values of these two columns. That is, the third column should say original if the values in col_a equal the values in col_b and replica otherwise.
Example:
col_a col_b
1234 1234
1235 1234
1236 1234
1237 1234
1321 1321
Expected Outcome:
col_a col_b type
1234 1234 original
1235 1234 replica
1236 1234 replica
1431 1431 original
1321 1431 replica
I tried the following code, but it doesn't seem to work.
type = []
for x in df['col_a'] and y in df['col_b']:
if x == y:
type.append('original')
else:
type.append('replica')
df['type'] = [type]
I am a newbie in Python, so I might be overlooking some crucial basic steps.