已解决,读取this
需要一些帮助来理解这个奇怪的行为吗
我有两个阵列。在
A = np.array([ [5338, 300],
[4970, 400],
[5339, 150],
])
B = np.array([
[349154, 5338, 100],
[349155, 5338, 100],
[349156, 5338, 100],
[349157, 5338, 100],
[349158, 5338, 100],
[349159, 5338, 100],
[349159, 4970, 50],
[349160, 4970, 50],
[349179, 4970, 50],
[349181, 4970, 50],
[349192, 4970, 50],
[349113, 4970, 50],
[349124, 4970, 50],
[349135, 4970, 50],
[349146, 4970, 50],
[349157, 4970, 50],
[349178, 4970, 50],
[449124, 5339, 50],
[549135, 5339, 50],
[649146, 5339, 50],
[749157, 5339, 50],
[849178, 5339, 50]
])
bpallets = []
#We iterate array A
for a in A:
#create a mask to get values from array B where B index 1 equal's to a index 0
mask = B[:,1] == a[0]
#retrieve the values
b = B[mask]
#filter array b by conditioning cumsum to stop when it reaches the value of Array "A" index 2
reached = b[np.where(b[:,2].cumsum() >= a[1] )]
bpallets.append(reached)
这样做的目的是在数组“A”索引列2中,由于某种原因,在 A、 条件失败。:(
这是我的输出。在
^{pr2}$提前Tks!!!在
不要打扰大家,找到我的答案,我改变了过滤器的逻辑,通过一个负掩模得到b上的元素。在
这个变化给了我所有的“假”,累计数低于a[1]。在
输出
^{pr2}$相关问题 更多 >
编程相关推荐