Horje
dividing counter object in python Code Example
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})




Python

Related
python quickly goto line in file Code Example python quickly goto line in file Code Example
how to make a new column with explode pyspark Code Example how to make a new column with explode pyspark Code Example
pyspark dataframe to single csv Code Example pyspark dataframe to single csv Code Example
python list to bytes Code Example python list to bytes Code Example
python string: immutable string Code Example python string: immutable string Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
9