Categories
Python Answers

How to convert NumPy array into Python List structure?

Spread the love

Sometimes, we want to convert NumPy array into Python List structure.

In this article, we’ll look at how to convert NumPy array into Python List structure.

How to convert NumPy array into Python List structure?

To convert NumPy array into Python List structure, we can use the tolist method.

For instance, we write

import numpy as np
l = np.array([[1,2,3],[4,5,6]]).tolist()

to create an NumPy array with np.array.

Then we call tolist on the NumPy array to return a list with the items that we create the array with.

Conclusion

To convert NumPy array into Python List structure, we can use the tolist method.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *