NumPy ndarray.tolist() Method | Convert NumPy Array to List Last Updated : 05 Feb, 2024 Comments Improve Suggest changes Like Article Like Report The ndarray.tolist() method converts a NumPy array into a nested Python list. It returns the array as an a.ndim-levels deep nested list of Python scalars. Data items are converted to the nearest compatible built-in Python type. Example Python3 import numpy as np gfg = np.array([1, 2, 3, 4, 5]) print(gfg.tolist()) Output[1, 2, 3, 4, 5] SyntaxSyntax: ndarray.tolist() Parameters: none Returns: The possibly nested list of array elements. How to Convert NumPy Array to Python ListTo convert a NumPy array to a Python list we use ndarray.tolist method of NumPy library in Python. It returns a copy of the array data as a Python list (Nested list in case of a multi-dimensional array). Let us understand it better with an example: Example:In this example, we can see that by using ndarray.tolist() method, we can have the list of data items in ndarray. Python3 # import the important module in python import numpy as np # make an array with numpy gfg = np.array([[1, 2, 3, 4, 5], [6, 5, 4, 3, 2]]) # applying ndarray.tolist() method print(gfg.tolist()) Output[[1, 2, 3, 4, 5], [6, 5, 4, 3, 2]] Comment More infoAdvertise with us Next Article NumPy ndarray.tolist() Method | Convert NumPy Array to List J jitender_1998 Follow Improve Article Tags : Python Python-numpy Python numpy-ndarray Practice Tags : python Similar Reads Convert Python List to numpy Arrays NumPy arrays are more efficient than Python lists, especially for numerical operations on large datasets. NumPy provides two methods for converting a list into an array using numpy.array() and numpy.asarray(). In this article, we'll explore these two methods with examples for converting a list into 4 min read Pandas Dataframe.to_numpy() - Convert dataframe to Numpy array to_numpy() method allows you to convert a Pandas DataFrame into a NumPy array, enabling efficient numerical operations, faster computations, and smooth interoperability with libraries that require NumPy arrays. Example:Pythonimport pandas as pd df = pd.DataFrame( [[1, 2, 3], [4, 5, 6], [7, 8, 9], [1 3 min read Ways to Convert a Python Dictionary to a NumPy Array The task of converting a dictionary to a NumPy array involves transforming the dictionaryâs key-value pairs into a format suitable for NumPy. In Python, there are different ways to achieve this conversion, depending on the structure and organization of the resulting array.For example, consider a dic 3 min read How to convert NumPy array to dictionary in Python? The following article explains how to convert numpy array to dictionary in Python. Array in Numpy is a table of elements (usually numbers), all of the same type, indexed by a tuple of positive integers. In Numpy, number of dimensions of the array is called rank of the array. A tuple of integers givi 3 min read NumPy ndarray.transpose() Method | Find Transpose of the NumPy Array The ndarray.transpose() function returns a view of the array with axes transposed. For a 1-D array, this has no effect, as a transposed vector is simply the same vector.For a 2-D array, this is a standard matrix transpose.For an n-D array, if axes are given, their order indicates how the axes are pe 2 min read Like