1
在基本層面我可以由另一個指數一個numpy的陣列,所以我可以返回一個數組的索引,使得:子集的一個numpy的陣列由另一個
a = [1,2,3,4,5,6]
b = [0.4, 0.5, 0.6, 0.7, 0.8, 0.9]
和0.6指數可以通過找到:
c = a[b==0.6]
但是,現在我有3D陣列,我無法讓我的腦袋圍繞我需要的東西。
我有3個數組:
A = [[21,22,23....48,49,50]] # An index over the range 20-50 with shape (1,30)
B = [[0.1,0.6,0.5,0.4,0.8...0.7,0.2,0.4],
..................................
[0.5,0.2,0.7,0.1,0.5...0.8,0.9,0.3]] # This is my data with shape (40000, 30)
C = [[0.8],........[0.9]] # Maximum values from each array in B with shape (40000,1)
我想知道(從A)的位置由(B)
索引在我的數據中每一個陣列的最大值(C)我曾嘗試:
D = A[B==C]
,但我不斷收到一個錯誤:
IndexError: index 1 is out of bounds for axis 0 with size 1
就其本身而言,我可以得到:
B==C# prints as arrays of True or False
,但我不能從A
檢索索引位置任何幫助表示讚賞!
相應的值'(B == C).shape'是'(40000,30 )'。這與A的形狀如何相對應? – Eric