文档介绍:数据科学基础(PYTHON)大作业
一、Chipotle餐厅案例分析
数据读入
import pandas as pd
new=('D:/qqfile/data2020/data2020/(subset=['order_id'],keep='last')#按照订单号列进行删除,保留
最后一次出现的数据
In [45]: (subset=['order_id,],keep='last,)
Out[45]:
order_id quantity
item_name \
3
1
1
Chips and Tomatillo-Green Chili Salsa
4
2
2
Chicken Bowl
6
3
1
Side of Chips
8
4
1
Steak Soft Tacos
10
5
1
Chips and Guacamole
4611
1830
1
Veggie Burrito
4614
1831
1
Bottled Water
4616
1832
1
Chips and Guacamole
4618
1833
1
Steak Burrito
4621
1834
1
Chicken Salad Bowl
choice_description item_price
3
NaN $
4
[Tomatillo-Rec
Chili
Salsa (Hot), [Black Beans $
6
NaN $
8
[Tomatillo Green Chili Salsa, [Pinto Beans, Ch $
10
NaN $
4611
[Tomatillo Green Chili Salsa, [Rice, Fajita Ve... $
4614
NaN $
4616
NaN $
4618
[Fresh Tomato
Salsa,
[Rice, Sour Cream, Cheese… $
4621
[Fresh Tomato
Salsa,
[Fajita Vegetables, Pinto $
[1834
rows x 5 columns]
自定义查询
一共有多少种不同的菜品被下单
new['item_name'].nunique()
In [15]: new['itemname'].unique()
Out[15]:
array(['Chips and Fresh Tomato Salsa', 'Izze', 'Nantucket Nectar', 'Chips and Tomatillo-Green Chili Salsa', 'Chicken Bowl', 'Side of Chips *, 'Steak Burrito', 'Steak Soft Tacos', 'Chips and Guacamole', 'Chicken Crispy Tacos', 'Chicken Soft Tacos', 'Chicken Burrito', 'Canned Soda', 'Barbacoa Burrito', 'Carnitas Burrito', 'Carnitas Bowl', 'Bottled Water', 'Chips and Tomatillo Green Chili Salsa', 'Barbacoa Bowl', 'Chips1, 'Chicken Salad Bowl1, 'Steak Bowl', 'Barbacoa Soft Tacos', 'Veggie Burrito''Veggie Bowl', 'Steak Crispy Tacos1, 'Chips and Tomatillo Red Chili Salsa', 'Barbacoa Crispy Tacos *, 'Veggie Salad Bowl1, 'Chips and Roasted Chili-Corn Salsa', 'Chips and Roasted Chili Corn Salsa', 'Carnitas Soft Tacos', 'Chicken Salad', 'Canned Soft Drink', 'Steak Salad Bowl', '6 Pack Soft Drink', 'Chips and Tomatillo-Red