Question #611

How to create an NumPy array from a list?

Answer

The best way to create a NumPy array from a list is to use the method numpy.array(), here is an example:

>>> import numpy as np
>>> list = [[1, 2], [3, 4], [5, 6]]
>>> a = np.array(list)
array([[1, 2],
       [3, 4],
       [5, 6]])

4 events in history
Answer by Alphonsio 01/11/2021 at 03:35:00 PM

The best way to create a NumPy array from a list is to use the method numpy.array(), here is an example:

>>> import numpy as np
>>> list = [[1, 2], [3, 4], [5, 6]]
>>> a = np.array(list)
array([[1, 2],
       [3, 4],
       [5, 6]])

Answer by Alphonsio 01/11/2021 at 03:33:59 PM

The best way to create a NumPy array from a list is to use the method numpy.array(), here is an example:

>>> import numpy as np
>>> list = [[1, 2], [3, 4], [5, 6]]
>>> a = np.array(list)
array([[1, 2],
       [3, 4],
       [5, 6]])

Answer by Alphonsio 01/11/2021 at 03:33:18 PM

The best way to create a NumPy array from a list is to use the method numpy.array(), here is an example:

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

Question by Alphonsio 01/11/2021 at 03:30:56 PM
How to create an NumPy array from a list?
# ID Query URL Count

Icons proudly provided by Friconix.