Count the Frequency of Elements in a List|DATA ENGINEER| TOP MOST PYTHON INTERVIEW QUESTION SERIES |

preview_player
Показать описание
Hello Guys, If you like this video please share and subscribe to my channel.

Full Playlist of Interview Questions of SQL:
Full Playlist of Snowflake SQL:
Full Playlist of Golang:
Full Playlist of NumPY Library:
Full Playlist of PTQT5:
Full Playlist of Pandas:

#interviewquestion #pythonbeginners
#Geekcoders,#Sagarprajapati,#Freecontent,#Azure,#Dataengineer,#Python,SQL,Data,#Database,#Database,#Engineering,#Databricks,#Azuredatafactory,#Spark,#pythonlist
Рекомендации по теме
Комментарии
Автор

This logic also worked for me.l=[1, 2, 3, 4, 5, 6, 7, 8, 9, 9, 9, 4, 5, 5]
dic={}
for i in s:
if i not in dic:
dic[i]=1
else:
dic[i]+=1
print(dic)

venugopal-ncnz
Автор

Hi Sagar! Thanks for the content
My approach
d={}
for i in new_list:
if i in d:
d[i]=d[i]+1
else:
d[i]=1
a=dict(sorted(d.items()))
print(a)

mohdtoufique
Автор

Hi Sagar, will this work?
%py
li =[1, 2, 3, 4, 5, 2, 3, 6, 6, 7, 6, 6]
d = dict((i, li.count(i)) for i in li)
print(d)
l = sorted(d.items(), key=lambda x:x[1], reverse=True)

dict(l)

Thanks in advance

SomwritaDe
Автор

def frequencyWord(input_list):
wfreq = [input_list.count(w) for w in input_list]
return dict(zip(input_list, wfreq))

sourbhydv