1# importing library
2import numpy
3
4# initilizing list
5lst = [1, 7, 0, 6, 2, 5, 6]
6
7# converting list to array
8arr = numpy.array(lst)
9
10# displaying list
11print ("List: ", lst)
12
13# displaying array
14print ("Array: ", arr)
1# Basic syntax:
2numpy_array.tolist()
3
4# Example usage:
5your_array = np.array([[1, 2, 3], [4, 5, 6]])
6your_array
7--> array([[1, 2, 3],
8 [4, 5, 6]])
9
10your_array.tolist()
11--> [[1, 2, 3], [4, 5, 6]]
1x=[[1,2],[1,2,3],[1]]
2y=numpy.array([numpy.array(xi) for xi in x])
3type(y)
4# <type 'numpy.ndarray'>
5type(y[0])
6# <type 'numpy.ndarray'>