Numpy: Indexing over the last axis when you don't know the rank in advance Numpy: Indexing over the last axis when you don't know the rank in advance numpy numpy

Numpy: Indexing over the last axis when you don't know the rank in advance


b = a[..., -k:]

This is mentioned in the docs.