Count Occurrences of Each Element in List in Python | Counter() Constructor of collections Module

Описание к видео Count Occurrences of Each Element in List in Python | Counter() Constructor of collections Module

How to count the occurrences of each item in a list in the Python programming language. More details: https://statisticsglobe.com/count-occ...
This tutorial was created in collaboration with Paula Villasante Soriano: https://statisticsglobe.com/paula-vil...
Python code of this video:

my_list = ['red', 'blue', 'red', 'green', 'orange', 'blue', 'green', 'yellow', 'purple', 'blue']
print(my_list)

from collections import Counter

Counter(my_list)

import pandas as pd

pd.Series(my_list).value_counts()

[[x,my_list.count(x)] for x in set(my_list)]

def counts(a):
dic = {}
for j in a:
if j in dic:
dic[j] +=1
else:
dic[j] =1
return dic

counts(my_list)

Follow me on Social Media:
Facebook – Statistics Globe Page:   / statisticsglobecom  
Facebook – R Programming Group for Discussions & Questions:   / statisticsglobe  
Facebook – Python Programming Group for Discussions & Questions:   / statisticsglobepython  
LinkedIn – Statistics Globe Page:   / statisticsglobe  
LinkedIn – R Programming Group for Discussions & Questions:   / 12555223  
LinkedIn – Python Programming Group for Discussions & Questions:   / 12673534  
Twitter:   / joachimschork  

Music by bensound.com

Комментарии

Информация по комментариям в разработке