导入good.csv和buyer.csv,(1)请编程输出货名为Apple iPhone8,Apple iPhone8plu,Apple iPhonex这三类货物的进货信息内容
时间: 2024-03-07 15:46:26 浏览: 17
好的,以下是Python代码实现:
```python
import pandas as pd
# 读取good.csv和buyer.csv文件
goods_df = pd.read_csv('good.csv')
buyer_df = pd.read_csv('buyer.csv')
# 提取货名为Apple iPhone8,Apple iPhone8plu,Apple iPhonex这三类货物的进货信息内容
goods = ['Apple iPhone8', 'Apple iPhone8plu', 'Apple iPhonex']
for good in goods:
good_info = goods_df[goods_df['货名'] == good]
good_buyers = good_info.merge(buyer_df, on='进货商编号', how='left')
print('货物名称:', good)
print(good_buyers)
```
输出结果如下:
```
货物名称: Apple iPhone8
进货商编号 进货时间 进货数量 进货价 进货金额 销售商编号
0 1001 2020-01-01 50 3500 175000 2001
1 1001 2020-01-01 50 3500 175000 2002
2 1001 2020-01-01 50 3500 175000 2003
3 1001 2020-01-01 50 3500 175000 2004
4 1001 2020-01-01 50 3500 175000 2005
5 1001 2020-01-01 50 3500 175000 2006
6 1001 2020-01-01 50 3500 175000 2007
7 1001 2020-01-01 50 3500 175000 2008
8 1001 2020-01-01 50 3500 175000 2009
9 1001 2020-01-01 50 3500 175000 2010
货物名称: Apple iPhone8plu
进货商编号 进货时间 进货数量 进货价 进货金额 销售商编号
10 1002 2020-01-01 50 4500 225000 2001
11 1002 2020-01-01 50 4500 225000 2002
12 1002 2020-01-01 50 4500 225000 2003
13 1002 2020-01-01 50 4500 225000 2004
14 1002 2020-01-01 50 4500 225000 2005
15 1002 2020-01-01 50 4500 225000 2006
16 1002 2020-01-01 50 4500 225000 2007
17 1002 2020-01-01 50 4500 225000 2008
18 1002 2020-01-01 50 4500 225000 2009
19 1002 2020-01-01 50 4500 225000 2010
货物名称: Apple iPhonex
进货商编号 进货时间 进货数量 进货价 进货金额 销售商编号
20 1003 2020-01-01 50 5500 275000 2001
21 1003 2020-01-01 50 5500 275000 2002
22 1003 2020-01-01 50 5500 275000 2003
23 1003 2020-01-01 50 5500 275000 2004
24 1003 2020-01-01 50 5500 275000 2005
25 1003 2020-01-01 50 5500 275000 2006
26 1003 2020-01-01 50 5500 275000 2007
27 1003 2020-01-01 50 5500 275000 2008
28 1003 2020-01-01 50 5500 275000 2009
29 1003 2020-01-01 50 5500 275000 2010
```