I have a list of dictionaries.
Each dictionary has a colour attribute. For example:
{'att1':value1, 'att2': value2, 'colour': 'Red'}
The colou attribute is from a list of 15 maxium colours.
I have over a thousand of these dictionaries in the list. I need to find out what is the popular colour and how many instances of it there are? Simiilarly I need the second most popular colour, the number of instances of it, the third most, fourth most etc…
Can some fancy pythonic syntax help me out?
gives you a
defaultdictwith all the colours and their respective number. Displaying those in a sorted fashion is trivial.