from this question : Python: Best Way to remove duplicate character from string answer:
''.join(ch for ch, _ in itertools.groupby(string_to_remove)
I know how to remove duplicated letters exists only next to each other, how to apply this solution to column in pandas?
df:
df=pd.DataFrame({'A':['ODOODY','LLHHEELLO'],'B':['NNMminee','DDasdss']})
expected result:
A,B
ODODY,NMine
LHELO,Dasds
tried:
df['A'] = df['A'].apply(lambda x: ''.join(ch for ch, _ in itertools.groupby(x['A'])))
thanks !