Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

dividing counter object in python

from collections import Counter
mylist = ['red','green','blue','red','orange','red','green']

counts = Counter(mylist)
for item, count in counts.items():
    counts[item] /= 14

print(counts)
# Counter({'red': 0.21428571428571427, 'green': 0.14285714285714285, 
# 'blue': 0.07142857142857142, 'orange': 0.07142857142857142})
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #dividing #counter #object #python
ADD COMMENT
Topic
Name
8+1 =