Comment

Andrew

Hi all, I discovered this page while trying to write a simple one-liner to de-dupe lists with order preservation. I came up with the following using a list comprehension and slicing. The idea is to slice the list one index at a time and only add an element to the de-duped list if it does not yet exist in the slice. I'm not sure about performance but as far as readability goes I like the simplicity of this one.

series = [v for i, v in enumerate(series) if series[0:i].count(v) == 0]