How to save a list as numpy array in python?
Is possible to construct a NumPy array from a python list?
Solution 1:
First of all, I'd recommend you to go through NumPy's Quickstart tutorial, which will probably help with these basic questions.
You can directly create an array from a list as:
import numpy as np
a = np.array( [2,3,4] )
Or from a from a nested list in the same way:
import numpy as np
a = np.array( [[2,3,4], [3,4,5]] )
Solution 2:
you mean something like this ?
from numpy import array
a = array( your_list )