探索酒类消费数据
首先导入Pandas库
import pandas as pd
(1)将数据框命名为drinks;
drinks = pd.read_csv('drinks.csv')
(2)哪个大陆(continent)平均消耗的啤酒(beer)更多?
(drinks[['continent','beer_servings']].groupby(by=
['continent']).mean().sort_values(by=['beer_servings'],
ascending =False)).head(1)
(3)打印出每个大陆(continent)的红酒消耗(wine_servings)的描述性统计值;
drinks.groupby('continent').wine_servings.describe()
(4)打印出每个大陆每种酒类别的消耗平均值;
drinks.groupby('continent').mean()
(5)打印出每个大陆每种酒类别的消耗中位数;
drinks.groupby('continent').median()
(6)打印出每个大陆对spirit_servings饮品消耗的平均值,最大值和最小值。
drinks.groupby('continent').spirit_servings.describe()
数据表Github链接:https://github.com/Booting-O/Pandas-Practice.git