hulkingtickets hulkingtickets - 2 months ago 12
Python Question

Converting NumPy array into Python List structure?

How do I convert a NumPy array to a Python List (for example

[[1,2,3],[4,5,6]]
), and do it reasonably fast?

Answer

Use tolist():

import numpy as np
>>> np.array([[1,2,3],[4,5,6]]).tolist()
[[1, 2, 3], [4, 5, 6]]