我有一个数据集,我需要从具有不同连接关系(一对一,一对几,一对多,很多)的收货点(RP)和交货点(DP)分配值-一对一,多对少,多对多)。 这些收货和交货值需要按合同编号分配,并且收货和交货点之间的每个合同的值总和相等(即,收货金额==交货金额),但各个收货和交货金额可能不相等(即,不是仓位)包装问题)。 一对一关系很容易通过过滤来解决,其中合同编号的收货价值和交货价值之和只有一个(每一行共两行)。
很少(反之亦然)是有问题的。
DP从哪个RP接收分配都没有关系。
该问题的解决方案在某种程度上解决了当前的问题,这就是我正在努力解决的问题 R: Distributing an amount as evenly as possible II
我从星期六开始学习此工作项目的R。在excel中,我会在asc等级上执行min函数,但这在这里不起作用,因为在某些情况下我需要在保持RP&DP名称和合同编号的同时创建新行。
我在下面包括了一张图片。
任何指针都会有所帮助。
谢谢你, 卡尔
体积数据表
答案 0 :(得分:0)
这是我找到的解决方案。
print ('The summary of the positive and negative numbers of a matrix')
A=[[0 for i in range (col)] for j in range (fil)]
fil=int(input('Number of columns'))
col=int(input('Number of rows'))
auxp=0
auxn=0
for i in range (fil):
for j in range (col):
A[i][j]=int(input('Numbers of the matrix'))
for i in range (fil)(col):
for j in range (fil):
if (A[i][j]>0):
auxp=aup+A[i][j]
else:
if (A[i][j]<0):
auxn=auxn+A[i][j]
print ('The summary of the positive numbers is ',auxp)
print ('The summary of the negative numbers is ',auxn)
TypeError Traceback (most recent call last)
<ipython-input-16-83bec8a1085e> in <module>
9 for j in range (col):
10 A[i][j]=int(input('Numbers of the matrix'))
---> 11 for i in range (fil)(col):
12 for j in range (fil):
13 if (A[i][j]>0):
TypeError: 'range' object is not callable