Sometimes, we want to convert NumPy array into Python List structure.
In this article, we’ll look at how to convert NumPy array into Python List structure.
How to convert NumPy array into Python List structure?
To convert NumPy array into Python List structure, we can use the tolist method.
For instance, we write
import numpy as np
l = np.array([[1,2,3],[4,5,6]]).tolist()
to create an NumPy array with np.array.
Then we call tolist on the NumPy array to return a list with the items that we create the array with.
Conclusion
To convert NumPy array into Python List structure, we can use the tolist method.