x = [1, 2, 3, 100, 101, 102, 103, 200, 201, 202, 203]
を
y = [[1, 2, 3], [100, 101, 102, 103], [200, 201, 202, 203]]
に変換したい。
import numpy
thresh = 60
x = [1, 2, 3, 100, 101, 102, 103, 104, 200, 201, 202, 203]
y = [numpy.array(x)[i+1:j+1].tolist()
for i, j
in zip(numpy.concatenate([
[-1,],
[-1,],
numpy.where(numpy.diff(x) > thresh)[0]
]),
]),
numpy.concatenate([
numpy.where(numpy.diff(x) > thresh)[0],
numpy.where(numpy.diff(x) > thresh)[0],
[len(x),]
])
)
]
])
)
]