I am looking for code to accomplish following in Python (Snowflake solution would also work.)
column A (before transformation)
8->8->8->8->5->7
8->5->5->5->7->8->7->7
25->15->15->13->18
25->15->15->13->18->15
Need to dedupe numbers keeping the sequence intact. They are de-duped only if they are together.
column A (after transformation)
8->5->7
8->5->7->8->7
25->15->13->18->15
Thank you!
no idea how to do that.
You can remove consecutive duplicates by adding each item to a new list only if it doesn't match the prior item, or, as suggested by @juanpa.arrivillag in comments, you can use
itertoolsto accomplish this in one line.Here is an example:
When I run this I get the following output:
Let me know if you have any questions.
EDIT: Added the
itertoolsoneliner. Shoutout to @juanpa.arrivillag for the excellent one-liner.