I have a 3D numpy array and I want to shuffle it block wise in a particular axis while keeping the data in that block in it's original state. For instance I have an np array of shape (50, 140, 23) and I want to shuffle by making blocks of (50, 1, 23) on axis=1. So 140 blocks will be created and blocks should be shuffled on axis=1 while maintaining the data in blocks in it's original order. I read documentation about np.random.shuffle(x) but this only shuffles in first axis and we can't provide a block size to it.
Is there any function in numpy or a quick way to do this?
Add a comment
|