原文链接
一、数据集信息
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
chipo = pd.read_csv('/Users/Desktop/十套python练习/exercise_data/chipotle.tsv', sep = '\t')
chipo.head(10)#显示前十行
chipo.shape[0]#显示行数
chipp.shape[1]#显示列数
chipo.columns#打印列名称
chipo.index#打印索引

二、分类(groupby)
- 被下单数(order)最多的商品(item_name)是什么?
#提取数量和名称两行,按照itemname进行分类,再对quantity进行聚合操作sum
#as_index表示是否将item_name列的各项作为index,若为True,则下图的ChickenBowl等在最左边index列
bestSeller = chipo[['quantity','item_name']].groupby('item_name'

该博客主要探讨了Chipotle的订单数据分析,通过`df.groupby()`和`df.agg()`函数对数据进行分类和聚合操作。内容包括确定下单最多的商品、计算每单平均总价,并展示了根据国家、收入等字段进行分组并计算平均值、最大值和最小值的实例。
最低0.47元/天 解锁文章
624

被折叠的 条评论
为什么被折叠?



