Search
 
SCRIPT & CODE EXAMPLE
 

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})
Comment

PREVIOUS NEXT
Code Example
Python :: com.codahale.metrics.annotation.timed 
Python :: block url selenium python 
Python :: helper for FastAPI Users to create a super user 
Python :: one liner if else replacement in python 
Python :: 12 hr to 24 hour time conversion python 
Python :: updating file multiple times in pandas 
Python :: Math expressions with matplotlib 
Python :: pylesson 
Python :: merge nouns spacy 
Python :: python -m pip install --upgrade pip /usr/bin/python: No module named pip 
Python :: first and last upper 
Python :: set column as category datatype 
Python :: Why do we put r before a path name in Python 
Python :: to find keywords in a text spacy 
Python :: how to subtract up everything in a list python 
Python :: Printers Stampanti 
Python :: how list comprehension for 2D works 
Python :: Get y_hat, or predicted values of y based on x_values 
Python :: assign more than one variable at a time on a single line in python 
Python :: custom-field-list_display 
Python :: how to get the access of python on cmd 
Python :: theta hat symbol python code 
Python :: check processing bar of loop in python 
Python :: text files to words generator 
Python :: softmax for nparray 
Python :: pydub reproduce audiosegment 
Python :: how to use rbind() to combine dataframes 
Python :: how to make a square shape in python 
Python :: precondition error tensorflow predict 
Python :: cannot access modules from neighbouring directories jupyter notebook 
ADD CONTENT
Topic
Content
Source link
Name
3+9 =