Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

how to find most occurring items in sequence python

# Find most frequently occuring items in sequence 
words = [
'look', 'into', 'my', 'eyes', 'look', 'into', 'my', 'eyes',
'the', 'eyes', 'the', 'eyes', 'the', 'eyes', 'not', 'around', 'the',
'eyes', "don't", 'look', 'around', 'the', 'eyes', 'look', 'into',
'my', 'eyes', "you're", 'under'
]

from collections import Counter 
word_counts = Counter(words)
top_two = word_counts.most_common(2) # [('eyes', 8), ('the', 5)]
 
PREVIOUS NEXT
Tagged: #find #occurring #items #sequence #python
ADD COMMENT
Topic
Name
8+9 =