You can convert a list in the NumPy array with the following code. If you want to learn Python, I highly recommend reading This Book.
Method 1: Convert a list in NumPy array using np.array()
import numpy as np a = [1, 2, 3, 4] b = np.array(a) # display type of a print(type(a)) # display type of b print(type(b))
<class 'list'> <class 'numpy.ndarray'>
Method 2: Convert a list in NumPy array using np.asarray()
import numpy as np a = [1, 2, 3, 4] b = np.asarray(a) # display type of a print(type(a)) # display type of b print(type(b))
<class 'list'> <class 'numpy.ndarray'>
People are also reading:
What is Computer Vision? Examples, Applications, Techniques
Books for Machine Learning (ML)