2021年3月11日星期四

How do I divide a Numpy array along axis-0 into a list of equal sized numpy arrays?

For example array

x = np.array([1, 2, 3, 4, 5, 6])  

Divided into 4 "folds" along axis-0 would be like a list

[array([1]), array([2]), array([3]), array([4])]  

Clearly, for this to be achieved some data has to be removed. In this case the 5th and 6th element are. How can I split any array into equally-sized sub-arrays EVEN if they are not easily divisible by the number of sub-arrays necessary and data must be removed?

https://stackoverflow.com/questions/66591219/how-do-i-divide-a-numpy-array-along-axis-0-into-a-list-of-equal-sized-numpy-arra March 12, 2021 at 06:03AM

没有评论:

发表评论