Numpy index of the maximum with reduction - numpy.argmax.reduceat
问题 I have a flat array b : a = numpy.array([0, 1, 1, 2, 3, 1, 2]) And an array c of indices marking the start of each "chunk": b = numpy.array([0, 4]) I know I can find the maximum in each "chunk" using a reduction: m = numpy.maximum.reduceat(a,b) >>> array([2, 3], dtype=int32) But... Is there a way to find the index of the maximum <edit> within a chunk </edit> (like numpy.argmax ), with vectorized operations (no lists, loops)? 回答1: Borrowing the idea from this post. Steps involved : Offset all