Converting list of Arrays to list of Lists?
You can use tolist()
in a list comprehension:
>>> [l.tolist() for l in list1]
[[0.0], [0.0], [0.0, 0.5], [0.5], [0.5], [0.5, 0.69], [0.69, 0.88], [0.88], [0.88], [0.88], [0.88, 1.0], [1.0, 1.1], [1.1], [1.1], [1.1], [1.1, 1.5], [1.5, 2.0], [2.0], [2.0]]
Just call ndarray.tolist()
on each member array.
l = [arr.tolist() for arr in l]
This should be faster than building a NumPy array on the outer level and then calling .tolist()
.