a = np.array([1, 2])
a.tolist()
import numpy as np
>>> np.array([[1,2,3],[4,5,6]]).tolist()
[[1, 2, 3], [4, 5, 6]]
# Basic syntax:
numpy_array.tolist()
# Example usage:
your_array = np.array([[1, 2, 3], [4, 5, 6]])
your_array
--> array([[1, 2, 3],
[4, 5, 6]])
your_array.tolist()
--> [[1, 2, 3], [4, 5, 6]]
>>> a = np.array([1, 2])
>>> list(a)
[1, 2]
>>> a.tolist()
[1, 2]
# make np array
np_arr = np.array(['a','b','c'])
# np array to list
py_list = np_arr.tolist()
print(py_list)
# output: ['a','b','c']