With the help of
numpy.ndarray.tolist() method, we can have the list of data elements which is converted from an ndarray using
Returns: The possibly nested list of array elements.
Example #1 :
In this example, we can see that by using
ndarray.tolist() method, we can have the list of data items in ndarray.
[1, 2, 3, 4, 5]
Example #2 :
[[1, 2, 3, 4, 5], [6, 5, 4, 3, 2]]
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning – Basic Level Course