remove repetitive characters from the specified column of a given DataFrame code example
Example 1: remove repetitive characters from the specified column of a given DataFrame
cols = ["col1","col2","col3"]
de_dup = a[cols].loc[(a[cols].shift() != a[cols]).any(axis=1)]
Example 2: remove repetitive characters from the specified column of a given DataFrame
In [82]:
a.loc[a.diff() != 0]
Out[82]:
1 1
2 2
4 3
5 2
dtype: int64