Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python count the frequency of words in a list

from collections import Counter
list1=['apple','egg','apple','banana','egg','apple']
counts = Counter(list1)

print(counts)
# Counter({'apple': 3, 'egg': 2, 'banana': 1})
Comment

PREVIOUS NEXT
Code Example
Python :: blender python set object location 
Python :: python what does yield do 
Python :: get video width and height cv2 
Python :: python convert querydict to dict 
Python :: pandas read csv with index 
Python :: filter list with python 
Python :: python datetime round to nearest hour 
Python :: extract numbers from string python 
Python :: python copy dir 
Python :: pandas capitalize column 
Python :: tkinter minsize 
Python :: pandas standard deviation on column 
Python :: parse youtube video id from youtube link python 
Python :: import randomforestclassifier 
Python :: python generate table 
Python :: sort_values 
Python :: openpyxl font 
Python :: python console animation 
Python :: subplot matplotlib set limits 
Python :: linear search in python 
Python :: cv2 hconcat 
Python :: how to align text in tkinter 
Python :: python extract specific columns from pandas dataframe 
Python :: imbade image to jupyter notebook 
Python :: upload file in colab 
Python :: cv2 show image 
Python :: python join generators 
Python :: python is letter or number functin 
Python :: django select database for migrate 
Python :: how to rotate the x label for subplot 
ADD CONTENT
Topic
Content
Source link
Name
6+5 =