As a result of my analysis, I will have a list where every measurement will occur twice. There might be double measurements (1 is measured twice in this case)
example_list = [1, 2, 3, 4, 1, 1, 2, 1, 3, 4]
My desired outcome:
outcome = [1, 2, 3, 4, 1]
Order does not matter, as long as every measurement only occurs once.
Since there might be double measurements, I cannot use unique().
Is there a way to efficiently half the list so every measurement only occurs once?
Edit for clarification: The list elements from double measurements will occur 4 (in this case) or more times, the ones from repeated measurements will occur twice
>Solution :
If there is no logic as to where the elements are in the list that need to be discarded, then one option is to use Counter, and halve the counts:
from collections import Counter
c = Counter(example_list)
for key in c:
c[key] //= 2
lst = list(c.elements())
For your example input, lst will be [1, 1, 2, 3, 4]