Question #611

# How to create an NumPy array from a list?

Merged questions

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 PMThe 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 PMThe 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`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 PMHow to create an NumPy array from a list?

# | ID | Query | URL | Count |
---|

Icons proudly provided by Friconix.