Let's say I have a python list:
foo = ['A', 'A', 'A', 'B', 'C', 'C']
How would I be able to extract the "least occurring" elements in the list?
Finding the majority elements is easier, doing the following:
print(max(foo, key=foo.count))
'A'
However, how could I efficiently find the least occurring? In the above example, it's 'B'
.
In terms of lists whereby all counts are the same, e.g. ['A', 'B', 'C', 'D']
, I think all items are "least occurring".