'Remove consecutive duplicate words from a comma separated string [duplicate]
If I have a string in a column that is separated by commas:
"apple, apple, banana, pear, apple"
How would I remove only consecutive duplicated words? My desired output would look like this:
"apple, banana, pear, apple"
The words in the string are separated by commas. I understand in [this post] How do I use itertools.groupby()? if the words are in a list this will work, but my issue is slightly different in that it is a single string and there are commas after each word. Thank you in advance.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
