Python Grouping Data Using Itertools Groupby

preview_player
Показать описание
In this Python tutorial we will go over how to group data elements in different ways and get counts for those different data elements, etc. using the itertools module groupby function.
Рекомендации по теме
Комментарии
Автор

Below is another way to get a tally count and see the unique values in a data set.

# create tally count using dictionary
l = ['a', 'a', 'b', 'a', 'b', 'c', 'a', 'a', 'b', 'c', 'b', 'c']
d = {}
for i in l:
if i not in d:
d[i] = 1
else:
d[i] += 1
print(d)
# prints {'a': 5, 'b': 4, 'c': 3}

# find unique values
print(set(l))
{'c', 'b', 'a'}

RyanNoonan
Автор

Thanks bro what a great tutorial! Very clear

shutingzhang
Автор

I was looking for group by then sort by count descending, now I can do it easily. Thanks a lot.

hypocritekiller
Автор

Thanks Ryan, you did a great job explaining it. Very helpful

sandeepnimmagadda
Автор

Thanks..It was helpful to understand groupby().

rishabhjain
Автор

thank you for the video. it helped a lot.

stoneskull
Автор

Thanks for the tutorial, very helpful!

takosenpai
Автор

Nice video and great explanation. Just increase the font size. this is difficult to see

swadhikarc
Автор

Nice video to understand groupby funcion

ankitthakar
Автор

i learnt sth and after a week i forgot it..have you any advice folk?

oddnumber
Автор

spyder IDE can also be installed using pip:
pip install -U spyder

udhayprakashpethakamsetty