How to use groupby() to group categories in a pandas DataFrame

preview_player
Показать описание
In this video we go over how to group categories of data using the grouby() operation in pandas. We use the popular Titanic data set commonly used when learning data science. We look at how to group on a single criteria on a single column. Then we move on how to group with multiple columns, then multiple groups, multiple groups and multiple columns, and how to look at multiple groupby functions in a single command. As a bonus, I'll show you a trick on how to minimize the number of groups which can improve the interpretability of you data.

▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬

$15 off Annual Dataquest subscription

▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬

▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬

Did you find this video helpful? Consider subscribing for weekly tips, tricks, and tutorials.

Link to Data

0:00 Intro
0:18 Data Overview
1:08 Groupby single col & function
1:55 Multiple cols grouped
2:40 Multiple grouping cols
3:20 Multiple functions flat df
3:43 Multiple functions
4:35 Quick tip
Рекомендации по теме
Комментарии
Автор

Thanks a lot! You saved me days! I'm literally crying rn. So pricise and to the point. Love the content

ShiladityaBiswasNow
Автор

I have seen three of your videos so far, all were very well thought out. Really helpful. You deserve many more subscribers!

imad_uddin
Автор

Just what we needed . Awesome content 🙌🏼

aishwaryapattnaik
Автор

Dude thank you sooo much. Finally someone with proper english explained things properly

rashadm.sadigov
Автор

Brilliant. It had exactly what i needed. Multiple groups and the splitting trick

sgerodes
Автор

🙏🙏🚩🚩🙏🙏Truly sir great lecture I had been trying to understand group by in pandas since last 25 days, but no-one was able to clear my confusion. But you sir explained me brilliantly and I am really so obliged of you. Thanks and I subscribed you and share on Facebook page, from Banaras City, India 😄😄😄🙏🙏🙏🙏🙏🙏

DuniyaJahan
Автор

I had to watch this a couple times too hear that part around 4:18 about why groupby will only return those who survived. It is good you added that. Now that I understand that, I can take a shot at age groups for the Titanic.

crystalchaung
Автор

Thank you very much for sharing! It really helped me, was exactly what I was looking for. People like you are blessed ang good people helping to develop this world! I just subscribed, follow and will share in my groups!

tonianibal
Автор

ok this is a mad comprehensive information that is explained amazingly briefly and clearly within just 7 min.

Aleqsie
Автор

Good step by step tutorial. But one thing you missed by Groupby multi columns, and apply different aggregate function. example: [column A, column B] A=sum, B=average. something like that

lightningmi
Автор

Thanks for the great video. Im wondering about how you could group the ages in intervals of 10 years. I feel like you probably wouldnt use cut for that since you would need to know the highest / lowest age in order to determine how many cuts you need. Do you have a recommendation on how to do that?

denisml
Автор

Awesome 👌. Clear crystal 🔮.
I specially like the bin trick, straightforward. That is really amazing 👏 😍. I had to break into intervals using numpy select ( ) or user defined function with apply ( ) to get the same result with the bin method.
Keep it up.

afonsoosorio
Автор

Simple and informative i love this video and am saving it for future references! Thank you!

jackfarah
Автор

Great video! so clear... It helps me a lot! Tks from Brazil!)

carolinamalosabastos
Автор

This is one of the best videos EVER! really helpfull! Thanks a LOT!

InteligenciadeNegocios
Автор

THANK YOU!!! that last tip is a life saver

Monkeysal
Автор

concise, short, illustrious!! Thanks alot!!!

rohitekka
Автор

Neat and objective!!!
Thanks for sharing. I do appreciate your content.

vitorribeirosa
Автор

Thank you for your detailed demonstrations.

zebramc
Автор

Thanks a lot i am searching this in entire weeks on articles.

skye