For Counting the occurrences there are many ways
1) Using count()
For Example:
Categories = [12,34,45,56,67,12,12,34,45,56,56,45,56]
Categories.count(12)
Output
3
2) Counting all occurrences witjh count() method and using it either with or without dictionary
[[x,Categories.count(x)] for x in set(Categories)]
Output:
[[34, 2], [67, 1], [12, 3], [45, 3], [56, 4]]
dict((x,Categories.count(x)) for x in set(Categories))
Output:
{34: 2, 67: 1, 12: 3, 45: 3, 56: 4}
The Output will be the same but the way it is been displayed is different.
3) Using Counter form collections library
from collections import Counter
Counter(Categories)
Output:
Counter({12: 3, 34: 2, 45: 3, 56: 4, 67: 1})
Hope this helps.