Question #374   Submitted by Answiki on 01/11/2021 at 03:30:56 PM UTC

How to create an NumPy array from a list?

Answer   Submitted by Answiki on 01/11/2021 at 03:35:00 PM UTC

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 Answiki on 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 Answiki on 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 Answiki on 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 Answiki 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.