Skip to content Skip to sidebar Skip to footer

Is There Another Way To Split A List Into Bins Of Equal Size And Put The Remainder If Any Into The First Bin?

Given a sorted list: x = list(range(20)) I could split the list into equal sizes and put the remainder into the left bins as such: def split_qustions_into_levels(questions, num_b

Solution 1:

Maybe array_split() is what you want.

a = np.arange(20)
np.array_split(a, 6)

Post a Comment for "Is There Another Way To Split A List Into Bins Of Equal Size And Put The Remainder If Any Into The First Bin?"