Let\'s say my data frame contains these data:
>>> df = pd.DataFrame({\'a\':[\'l1\',\'l2\',\'l1\',\'l2\',\'l1\',\'l2\'], \'b\'
You can also use the string methods.
df['c'] = (df.a.str[-1] == df.b).astype(int)