我有这种结构:
[
array([ 0. , 4.5, 9. ]),
[
array([ 100., 120., 140.]),
[
array([ 1000., 1100., 1200.]),
array([ 1200., 1300., 1400.])
],
array([ 150., 170., 190.]),
[
array([ 1500., 1600., 1700.]),
array([ 1700., 1800.])
]
]
]
(其中array
s 是numpy.array
s)
如何编写一个给我的生成器:
(0, 4.5), (100, 120), (1000, 1100)
(0, 4.5), (100, 120), (1100, 1200)
(0, 4.5), (120, 140), (1200, 1300)
(0, 4.5), (120, 140), (1300, 1400)
(4.5, 9), (150, 170), (1500, 1600)
(4.5, 9), (150, 170), (1600, 1700)
(4.5, 9), (170, 190), (1700, 1800)
到目前为止,我唯一拥有的是:
def loop_bin(bins):
for i in range(len(bins)-1):
yield [bins[i], bins[i+1]]