我的数据帧有问题。我无法正确显示我的值。我不断得到索引错误,但现在我得到了我的表显示和输入是不正确的。 这就是我得到的: 我想要第二行显示安迪的15,0,0。 预期产出:
customers = [u'Becky Buyer - Address Two', u'Andy Buyer - Andy nguyen']
plu_parts = [12834L, 11521L, 11164L]
cases = numpy.zeros(shape=(len(plu_parts),len(customers)))
我在这里写道:
for i in range(len(plu_parts)):
for j in range(len(customers)):
plu_sets = [x for x in obs_plu_code_buyer if x['seller_inventory__plu_code_id'] == plu_parts[i] and x['purchase_order_line__purchase_order__buyer__company_name'] + str(" - ") + x['purchase_order_line__purchase_order__delivery_address__contact'] == customers[j]]
print(plu_sets)
if len(plu_sets) > 0:
cases[i][j] = int(plu_sets[0]['num_cases'])
这让我
cases = [[ 100. 10.]
[ 13. 0.]
[ 50. 0.]]
veggies = [u'Conventional Any Custom Mix , 90% Iceberg w/ carrot and red cabbage , 4/5#', u'Conventional Cabbage , Green , 45#', u'Conventional Cabbage , Napa , 15#']
dd = 'Delivery Dated ' + delivery_date.strftime('%m/%d/%Y')
py = pd.DataFrame({dd :customers})
for k in range(0,len(veggies)):
d = [int(row) for row in cases[:,0]]
py.insert(k+1,veggies[k],d[k])
感谢所有的帮助。 编辑:包含reprex代码
在创建数据帧时,使用
.T
转置numpy数组cases
:相关问题 更多 >
编程相关推荐