filmov
tv
Python Program Method 3: Break a list into chunks of size N in Python using Numpy
Показать описание
import numpy as np
arr = range(30)
Output:
[array([0, 1, 2, 3, 4]),
array([5, 6, 7, 8, 9]),
array([10, 11, 12, 13, 14]),
array([15, 16, 17, 18, 19]),
array([20, 21, 22, 23, 24]),
array([25, 26, 27, 28, 29])]
arr = range(30)
Output:
[array([0, 1, 2, 3, 4]),
array([5, 6, 7, 8, 9]),
array([10, 11, 12, 13, 14]),
array([15, 16, 17, 18, 19]),
array([20, 21, 22, 23, 24]),
array([25, 26, 27, 28, 29])]