【发布时间】:2023-03-31 03:48:02
【问题描述】:
我正在使用 Python3。 我有三个列表,一个是产品经销商的名称,另一个是产品列表,另一个是产品分类,最后,我有两个数组。
每个经销商都提供 15 种产品。
distributors = ['d1', 'd2', 'd3', 'd4', 'd5']
products = ['apple', 'carrot', 'potato', 'avocado', 'pumkie', 'banana', 'kiwi', 'lettuce', 'tomato', 'pees', 'pear', 'berries', 'strawberries', 'blueberries', 'boxes']
tips = ['fruit', 'vegetables', 'random']
actual_prix = np.random.rand(15, 5)
prix_prox_year = np.random.rand(15,5)
数组的结构如下:行是按顺序排列的产品,列是按顺序排列的分销商。 我需要的输出如下:
Products Distributor Actual Next_year Type
0 apple d1 0.16147847 0.28173206 fruit
1 ... ... ... ... fruit
2 apple d5 ... ... fruit
... ... ... ... ... ...
15 boxes d5 ... ... random
这只是一个例子,因为我的数组有这个大小(1010, 33)。
有什么想法吗?
【问题讨论】:
-
您如何知道哪个经销商与哪些产品相关联?
标签: python arrays pandas list dataframe