element in numpy array.
Ex:arr =
[
[ [1,2,3] , [4,5,6] ]
[ [1,4,6] , [2,3,5] ]
]
Is a (2,2,3) array
Instead of doing this:
for row in arr:
for item in row:
t = np.sum(item)
Is there any efficient method ?
If I understand what you mean, you can use the axis parameter in np.sum, so axis = 2 should give you the array you're looking for
Обсуждают сегодня