SyntaxFix
Write A Post
Hire A Developer
Questions
For this particular relationship, you could use np.sign:
np.sign
>>> df["C"] = np.sign(df.A - df.B) >>> df A B C a 2 2 0 b 3 1 1 c 1 3 -1