I need to find the frequency of elements in a list
a = [1,1,1,1,2,2,2,2,3,3,4,5,5]
output->
b = [4,4,2,1,2]
Also I want to remove the duplicates from a
a = [1,2,3,4,5]
I need to find the frequency of elements in a list
a = [1,1,1,1,2,2,2,2,3,3,4,5,5]
output->
b = [4,4,2,1,2]
Also I want to remove the duplicates from a
a = [1,2,3,4,5]
I would simply use scipy.stats.itemfreq in the following manner:
you may check the documentation here: http://docs.scipy.org/doc/scipy-0.16.0/reference/generated/scipy.stats.itemfreq.html
Yet another solution with another algorithm without using collections:
Since the list is ordered you can do this:
Output:
This answer is more explicit