How can you remove consecutive duplicates of a specific value?
I am aware of the groupby()
function but that deletes consecutive duplicates of any value.
See the example code below. The specific value is 2, in which I want to remove duplicates
import pandas as pd
from itertools import groupby
example = [1,1,5,2,2,2,7,9,9,2,2]
Col1 = pd.DataFrame(res)
# This does not work for just a specific number
res = [i[0] for i in groupby(Col1)]
The resulting DataFrame would be [1,1,5,2,7,9,9,2]