I would like to receive a dataset of N elements and group it every 59 elements, considering that the first element would have the index 0. The problem in this script is that in the sample.append(data [i])
part, it groups all the data again in a single list, I would like to divide it as follows. [[60 elements], [60 elementps], ...]
. Any suggestions for correction?
Script:
@staticmethod
def sampleDivision(data):
parts = int(len(data) / 60)
collections = []
i = 1
while i <= parts:
i * 60
collections.append(i * 59)
i += 1
print(collections)
i = 1
sample = []
for position in collections:
while i <= int(position):
sample.append(data[i])
i += 1
return sample
Output:
[68, 69, 68, 69, 70, 71, 75, 72, 73, 72, 72, 73, 72, 72, 73, 70, 71, 73, 72, 72, 71, 69, 68, 69, 68, 69, 68, 69, 68, 68, 68, 68, 69, 68, 69, 70, 71, 75, 72, 69, 68, 68, 68, 69, 68, 69, 70, 71, 75, 72, 69, 68, 69, 68, 69, 68, 69, 68, 68, 60, 60, 61, 60, 61, 65, 69, 69, 72, 73, 72, 72, 73, 72, 72, 73, 70, 71, 73, 75, 78, 80, 82, 84, 87, 84, 84, 83, 82, 79, 78, 76, 74, 73, 72, 72, 72, 71, 75, 72, 69, 68, 68, 68, 69, 68, 69, 70, 71, 75, 72, 69, 68, 69, 68, 69, 68, 69, 68]