Try changing, and then take the maximum:
import numpy as np
a = np.array([1,2,3,4,5,6,7,8,9])
>>> a.reshape((len(a) / 3, 3)).max(axis=1)
array([3, 6, 9])
If the length of the array is not divisible by a number, your question requires a larger definition in order to say what you mean in this case.
Edit @ajcr in the comments below shows a much better way to change:
>>> a.reshape((-1, 3)).max(axis=1)
source
share