**Answiki**on 01/11/2021 at 06:52:06 PM UTC

# In Python, how to create an empty NumPy array?

**Answiki**on 01/11/2021 at 03:30:27 PM UTC

There are several ways to create an **empty NumPy array in Python**. In the following we'll assume NumPy is imported according to the following:

`import numpy as np`

__Create an empty Numpy array:__

```
>>> a = np.array([])
array([], dtype=float64)
```

__Create a NumPy array filled with zero of a given size:__

```
>>> a = np.zeros([4,3])
array([[0., 0., 0.],
[0., 0., 0.],
[0., 0., 0.],
[0., 0., 0.]])
```

__Create an uninitialized NumPy array with a given size:__

```
>>> a = np.empty([2,2])
array([[5.e-324, 5.e-324],
[5.e-324, 0.e+000]])
```

**Answiki**01/11/2021 at 06:52:06 PM

**Answiki**on 01/11/2021 at 03:30:27 PM

There are several ways to create an **empty NumPy array in Python**. In the following we'll assume NumPy is imported according to the following:

`import numpy as np`

__Create an empty Numpy array:__

```
>>> a = np.array([])
array([], dtype=float64)
```

__Create a NumPy array filled with zero of a given size:__

```
>>> a = np.zeros([4,3])
array([[0., 0., 0.],
[0., 0., 0.],
[0., 0., 0.],
[0., 0., 0.]])
```

__Create an uninitialized NumPy array with a given size:__

```
>>> a = np.empty([2,2])
array([[5.e-324, 5.e-324],
[5.e-324, 0.e+000]])
```

**Answiki**on 01/11/2021 at 03:29:58 PM

There are several ways to create an **empty NumPy array in Python**. In the following we'll assume numpy is imported according to the following:

`import numpy as np`

__Create an empty Numpy array:__

```
>>> a = np.array([])
array([], dtype=float64)
```

__Create a NumPy array filled with zero of a given size:__

```
>>> a = np.zeros([4,3])
array([[0., 0., 0.],
[0., 0., 0.],
[0., 0., 0.],
[0., 0., 0.]])
```

__Create an uninitialized NumPy array with a given size:__

```
>>> a = np.empty([2,2])
array([[5.e-324, 5.e-324],
[5.e-324, 0.e+000]])
```

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