To drop consecutive duplicates with Python Pandas, we can use shift.
For instance, we write
a.loc[a.shift(-1) != a]
to check if the last column isn’t equal the current one with a.shift(-1) != a.
And then we put a.shift(-1) != a in loc to return a data frame without the consecutive duplicate values.