以太坊 ssh命令 unity overflow 存量客户 Jetbains全家桶 matplotlib curl servlets vcpkg jar arduino static 前端vue框架 后台界面模板 jquery去除空格 pytorch安装教程 基于bootstrap的框架 lora开发 oracle查看所有数据库 kubernetes实战 python输出 java重载和重写 java开发学习 java时间转时间戳 linux命令 linux启动 linux系统命令大全 怎么安装linux xp画图工具 房产证生成器 路由器辐射大吗 制作字幕的软件 dg分区 navicat注册机 视频修复工具 联发科mt6750 linux定时任务 python爬虫代码 ppt格式刷怎么用
当前位置: 首页 > 学习教程  > 编程语言

理想国pandas练习题5

2021/2/13 19:15:14 文章标签: 测试文章如有侵权请发送至邮箱809451989@qq.com投诉后文章立即删除

需求 现在我们有一组关于全球星巴克店铺的统计数据,如果我想知道美国的星巴克数量和中国的哪个多,或者我想知道中国每个省份星巴克的数量的情况,那么应该怎么办? 数据来源:https://www.kaggle.com/starbucks/store-lo…

需求

现在我们有一组关于全球星巴克店铺的统计数据,如果我想知道美国的星巴克数量和中国的哪个多,或者我想知道中国每个省份星巴克的数量的情况,那么应该怎么办?

数据来源:https://www.kaggle.com/starbucks/store-locations/data

数据获取

从文件中读取星巴克店铺数据

# 导入星巴克店的数据
starbucks = pd.read_csv("./data/starbucks.csv")

进行分组聚合

# 按照国家分组,求出每个国家的星巴克零售店数量
count = starbucks.groupby(['Country']).count()

画图显示结果

count['Brand'].plot(kind='bar', figsize=(20, 8))
plt.show()

假设我们加入省市一起进行分组

# 设置多个索引,set_index()
starbucks.groupby(['Country', 'State/Province']).count()

starbucks.csv

Brand,Store Number,Store Name,Ownership Type,Street Address,City,State/Province,Country,Postcode,Phone Number,Timezone,Longitude,Latitude
Starbucks,47370-257954,"Meritxell, 96",Licensed,"Av. Meritxell, 96",Andorra la Vella,7,AD,AD500,376818720,GMT+1:00 Europe/Andorra,1.53,42.51
Starbucks,22331-212325,Ajman Drive Thru,Licensed,"1 Street 69, Al Jarf",Ajman,AJ,AE,,,GMT+04:00 Asia/Dubai,55.47,25.42
Starbucks,47089-256771,Dana Mall,Licensed,Sheikh Khalifa Bin Zayed St.,Ajman,AJ,AE,,,GMT+04:00 Asia/Dubai,55.47,25.39
Starbucks,22126-218024,Twofour 54,Licensed,Al Salam Street,Abu Dhabi,AZ,AE,,,GMT+04:00 Asia/Dubai,54.38,24.48
Starbucks,17127-178586,Al Ain Tower,Licensed,"Khaldiya Area, Abu Dhabi Island",Abu Dhabi,AZ,AE,,,GMT+04:00 Asia/Dubai,54.54,24.51
Starbucks,17688-182164,"Dalma Mall, Ground Floor",Licensed,"Dalma Mall, Mussafah",Abu Dhabi,AZ,AE,,,GMT+04:00 Asia/Dubai,54.49,24.4
Starbucks,18182-182165,"Dalma Mall, Level 1",Licensed,"Dalma Mall, Mussafah",Abu Dhabi,AZ,AE,,,GMT+04:00 Asia/Dubai,54.49,24.4
Starbucks,23359-229184,Debenhams Yas Mall,Licensed,Yas Island,Abu Dhabi,AZ,AE,,,GMT+04:00 Asia/Dubai,54.61,24.46
Starbucks,30781-99022,Khalidiya Street,Licensed,Khalidiya St.,Abu Dhabi,AZ,AE,,26670052,GMT+04:00 Asia/Muscat,55.69,24.19
Starbucks,20423-205465,Eastern Mangroves,Licensed,"Al Salam Street, The Mangroves",Abu Dhabi,AZ,AE,,,GMT+04:00 Asia/Dubai,54.38,24.48
Starbucks,20424-205466,Nation Towers,Licensed,Corniche Street,Abu Dhabi,AZ,AE,,,GMT+04:00 Asia/Dubai,54.34,24.47
Starbucks,1579-122101,HCT Abu Dhabi Women's College Block,Licensed,"Najda Street, Higher Colleges of Technology",Abu Dhabi,AZ,AE,3167,26426280,GMT+04:00 Asia/Dubai,54.37,24.49
Starbucks,32595-122105,Standard Chartered Building,Licensed,"Khalidiya St., Beside Union Cooperative Society",Abu Dhabi,AZ,AE,3167,26359275,GMT+04:00 Asia/Muscat,55.69,24.19
Starbucks,24191-236428,International Tower,Licensed,"Capital Center, Adnec, Abu Dhabi",Abu Dhabi,AZ,AE,,,GMT+04:00 Asia/Dubai,54.7,24.3
Starbucks,24604-238367,Yas Mall 3,Licensed,YAS Island,Abu Dhabi,AZ,AE,,,GMT+04:00 Asia/Dubai,54.6,24.48
Starbucks,32029-110804,Blue Tower A,Licensed,"Street No.4, Muroor Road, Ground Floor",Abu Dhabi,AZ,AE,,26429255,GMT+04:00 Asia/Muscat,55.74,24.21
Starbucks,29560-238539,Corniche Park DT,Licensed,"Corniche  Road , Abu Dhabi",Abu Dhabi,AZ,AE,,,GMT+04:00 Asia/Dubai,54.34,24.47
Starbucks,32239-100001,Khalidiya Mall,Licensed,"Street No.26 of Khalidiya Area, Ground Floor, Shop No. A11",Abu Dhabi,AZ,AE,,26354740,GMT+04:00 Asia/Dubai,54.35,24.47
Starbucks,31719-103601,Al Wahda Mall,Licensed,"11th Street, Ground Floor, Main Entrance",Abu Dhabi,AZ,AE,,24437197,GMT+04:00 Asia/Dubai,54.37,24.47
Starbucks,20008-200004,Al Seef Village,Licensed,"Salam Street, Ministries District",Abu Dhabi,AZ,AE,,,GMT+04:00 Asia/Dubai,54.38,24.48
Starbucks,32767-131566,Shangri-La Souq,Licensed,"Shangri-La Souk, Um Al Nar",Abu Dhabi,AZ,AE,3167,25581641,GMT+04:00 Asia/Dubai,54.51,24.42
Starbucks,3886-141408,"Abu Dhabi University, Men's",Licensed,"Muroor Street, Abu Dhabi Mall",Abu Dhabi,AZ,AE,,24433824,GMT+04:00 Asia/Dubai,54.35,24.46
Starbucks,29539-254261,MUshrif Mall 1,Licensed,"25th st, Airport Road",Abu Dhabi,AZ,AE,971,,GMT+04:00 Asia/Dubai,54.66,24.41
Starbucks,28809-251348,Boutik Mall Sun & Sky,Licensed,"Shams Abu Dhabi, Al Reem Island",Abu Dhabi,AZ,AE,,,GMT+04:00 Asia/Dubai,54.41,24.5
Starbucks,34262-62540,Marina Mall,Licensed,Marina Mall,Abu Dhabi,AZ,AE,,02-6815883,GMT+04:00 Asia/Dubai,54.32,24.47
Starbucks,3178-141407,"Abu Dhabi University, Women's",Licensed,"Road Al Ain Abu Dhabi Road Number 22, Women Side",Abu Dhabi,AZ,AE,,25860492,GMT+04:00 Asia/Dubai,54.57,24.35
Starbucks,34260-17877,Hamdan Street,Licensed,Hamdan Street,Abu Dhabi,AZ,AE,,02-6261001,GMT+04:00 Asia/Muscat,55.62,24.21
Starbucks,21605-213406,Saadiyat Island,Licensed,Saadiyat Island,Abu Dhabi,AZ,AE,,,GMT+04:00 Asia/Dubai,54.44,24.54
Starbucks,1935-141406,Camellia Flowers,Licensed,"Khalidiya Area Khalidiya street, Behind Union Bank and Finance House",Abu Dhabi,AZ,AE,,02-6355542,GMT+04:00 Asia/Dubai,54.34,24.47
Starbucks,20113-195784,Deerfields,Licensed,"Sheikh Zayed Road, Al Bahia Area",Abu Dhabi,AZ,AE,,,GMT+04:00 Asia/Dubai,54.94,24.9
Starbucks,34227-33225,Abu Dhabi Mall,Licensed,"Al Salam Street, Tourist Club Area",Abu Dhabi,AZ,AE,,02-6454914,GMT+04:00 Asia/Dubai,54.37,24.5
Starbucks,17361-180588,Zayed University,Licensed,Corner of 16th Street and Aiport Road,Abu Dhabi,AZ,AE,,,GMT+04:00 Asia/Dubai,54.6,24.4
Starbucks,15938-165686,Bawabat Al Sharq,Licensed,Corner Al Ain Rd & Baniyas Rd,Abu Dhabi,AZ,AE,,,GMT+04:00 Asia/Muscat,55.77,24.48
Starbucks,16453-170544,Guardian Tower,Licensed,"31st Street, Danat Abu Dhabi",Abu Dhabi,AZ,AE,,02 6414214,GMT+04:00 Asia/Dubai,54.44,24.43
Starbucks,24085-235545,Ferrari World Welcome Pavilion,Licensed,Yas Island,Abu Dhabi,AZ,AE,,,GMT+04:00 Asia/Dubai,54.61,24.46
Starbucks,24932-239347,Al Mamoura,Licensed,"Al Mamoura, Al Muroor District",Abu Dhabi,AZ,AE,51133,,GMT+04:00 Asia/Dubai,54.39,24.46
Starbucks,18469-188844,Ministry of Interior,Licensed,Khaleej Al Arabi Street,Abu Dhabi,AZ,AE,,,GMT+04:00 Asia/Dubai,54.39,24.43
Starbucks,28810-251346,ADNOC Mushrif,Licensed,Airport Road,Abu Dhabi,AZ,AE,,,GMT+04:00 Asia/Dubai,54.66,24.41
Starbucks,1897-120044,Twin Towers 13th Street,Licensed,"3th street Abudhabi (Al Najda Street), Beside Al Masood Nissan Show Room",Abu Dhabi,AZ,AE,,26430239,GMT+04:00 Asia/Dubai,55.53,23.85
Starbucks,20772-207664,Al Falah Community,Licensed,Al Falah Village 2 Centre,Abu Dhabi,AZ,AE,,,GMT+04:00 Asia/Dubai,54.37,24.47
Starbucks,2176-143834,Abu Dhabi Police HQ,Licensed,13th Street,Abu Dhabi,AZ,AE,,02 4093231,GMT+04:00 Asia/Dubai,54.37,24.52
Starbucks,18530-169885,Western Region,Licensed,"Liwa Road, Madinat Zayed",Abu Dhabi,AZ,AE,,,GMT+04:00 Asia/Dubai,54.37,24.48
Starbucks,24931-239348,Raha Garden,Licensed,Raha Gardens Plaza,Abu Dhabi,AZ,AE,51133,,GMT+04:00 Asia/Dubai,54.37,24.47
Starbucks,29306-253248,Al Ain Ladies Club,Licensed,"Al Markhaniya , Al Ain, Al Markhaniya, Al Ain",Al Ain,AZ,AE,,,GMT+04:00 Asia/Muscat,55.4,24.12
Starbucks,17291-169884,Jahli Park,Licensed,"Sheikh Khalifa Bin Zayed Road, Jahli",Al Ain,AZ,AE,,,GMT+04:00 Asia/Dubai,55.29,25.24
Starbucks,32640-131563,Tawam Hospital,Licensed,"Al Ain Abu Dhabi Rd, Khalifa Bin Zayed, Al Makam Area",Al Ain,AZ,AE,3167,37677581,GMT+04:00 Asia/Muscat,55.65,24.19
Starbucks,34332-97778,Jimmy Mall,Licensed,"Baladia Road, Opposite Passport Office",Al Ain,AZ,AE,,37627680,GMT+04:00 Asia/Muscat,55.73,24.24
Starbucks,16257-166109,Al Ain Mall,Licensed,City Road,Al Ain,AZ,AE,,03 7849281,GMT+04:00 Asia/Dubai,55.39,25.1
Starbucks,1926-141411,Bawadi Mall,Licensed,Maziad Road After Hilton Roundabout,Al Ain,AZ,AE,,37840012,GMT+04:00 Asia/Muscat,55.81,24.16
Starbucks,24510-238164,Wahat Hili Mall,Licensed,"Unit RA 029, Wahat Hili Mall, Baniyas Street, Hili District",Al Ain,AZ,AE,,,GMT+04:00 Asia/Muscat,55.69,24.21
Starbucks,17788-183965,Oasis Hospital,Licensed,"Al Ain Street, Al Jahli",Al Ain,AZ,AE,,,GMT+04:00 Asia/Muscat,55.8,24.13
Starbucks,22963-226644,YAS Mall,Licensed,"Yas Island, Abu Dhabi",Abu Dhabi,DU,AE,,,GMT+04:00 Asia/Dubai,54.47,24.41
Starbucks,23197-228761,Al Ruwais Mall,Licensed,Al Ruwais,Abu Dhabi,DU,AE,,,GMT+04:00 Asia/Dubai,54.63,24.29
Starbucks,23549-231166,Shamkha Mall,Licensed,Al Shamkha,Abu Dhabi,DU,AE,,,GMT+04:00 Asia/Dubai,54.69,24.39

本文链接: http://www.dtmao.cc/news_show_700297.shtml

附件下载

相关教程

    暂无相关的数据...

共有条评论 网友评论

验证码: 看不清楚?