I have a dataframe df that looks like:
0 1 2 3 0 x a 1 x b 2 x c 3 x a 4 x b 5 x c 6 y a 7 y b 8 y c 9 z a 10 z b 11 z c 12 z a 13 z b 14 z c I want to delete rows where df[1]=="c" AND df[0]==df[0].shift(-1)
However I am not able to combine these 2 conditions. Here is my code:
m1 = (df[df[0].eq(df[0].shift(-1))]) m2 = (df[df[1].eq("x")]) df[~(m1 & m2)] I get error:
TypeError: unsupported operand type(s) for &: 'str' and 'str' If I try
df[~(m1 and m2)] I get error:
ValueError: The truth value of a DataFrame is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().