Let a
be some (not necessarily one-dimensional) NumPy array with n * m
elements along its last axis. I wish to "split" this array along its last axis so that I take every n
'th element starting from 0
up until n
.
To be explicit let a
have shape (k, n * m)
then I wish to construct the array of shape (n, k, m)
np.array([a[:, i::n] for i in range(n)])
my problem is that though this indeed return the array that I seek, I still feel that there might be a more efficient and neat NumPy routine for this.
Cheers!