When should I use a 'groupby' in pandas?
import pandas as pd
drinks = pd.read_csv("http://bit.ly/drinksbycountry")
drinks.head()
drinks.beer_servings.mean()
106.16062176165804
drinks.groupby('continent').beer_servings.mean()
continent
Africa 61.471698
Asia 37.045455
Europe 193.777778
North America 145.434783
Oceania 89.687500
South America 175.083333
Name: beer_servings, dtype: float64
drinks.groupby('continent').beer_servings.agg(['count','min','max','mean'])
drinks[drinks.continent=='Africa']
drinks.groupby('continent').mean()
%matplotlib inline
drinks.groupby('continent').mean().plot(kind='bar')
출처 : youtu.be/qy0fDqoMJx8
728x90
'AI월드 > ⚙️AI BOOTCAMP_Section 2' 카테고리의 다른 글
AdaBoost,아다부스트,decision tree,random tree_Day33(2) (0) | 2021.02.16 |
---|---|
bootstrap,bagging 복습_Day33 (0) | 2021.02.16 |
분류 정확도와 불균형, accuracy만 집중했을 때의 문제점_Day 31 (0) | 2021.02.15 |
혼동행렬, 정확도, 정밀도, 재현율 한번더정리 (0) | 2021.02.09 |
결정트리,랜덤포레스트,혼동행렬,교차검증 키워드 개념정리 (0) | 2021.02.08 |
댓글