Compare value against previous value for different column

55 Views Asked by At

What is the simplest way to compare one column against the previous value of another column, for each person - ideally without apply/lambda? In this example, "applez" vs "applet"

df     A         B      person
0    fruit    applet     abby
1    applez   cherry     abby
...
df.groupby("person").A.eq(df.groupby("person").B.shift())

Expected Output

0  NaN
1  False
0

There are 0 best solutions below