20/34
Part 6 of 8 · BandsLearn and do

Cut one huge table into bands of rows

Start a band at every multiple of band_rows, and stitch the bands back in order

A batch gives a pool something to share out. One huge table doesn't: a pool of 4 with one item runs it on one worker. So cut the table into bands, runs of consecutive rows, and share out the bands.

T = [[21, 19, 23], [25, -40, 24], [22, 20, 99], [24, 21, 22], [20, 18, 21]]

Cutting, running and stitching are one line each. group is the list of steps that runs on the bands:

bands = [table[top:top + band_rows] for top in range(0, len(table), band_rows)]
# one band at a time, for now
done = [run(band, group) for band in bands]
table = [row for band in done for row in band]
Predict

T has 5 rows, cut into bands of band_rows = 2. How many bands, and how big is the last?

Pick an answer above to see the rest