A new **ndarray object** can be constructed by any of the following array creation routines or using a low-level ndarray constructor.

It creates an uninitialized array of specified shape and dtype. It uses the following constructor −

```
numpy.empty(shape, dtype = float, order = 'C')
```

Parameter | Description | |||
---|---|---|---|---|

Shape |
Shape of an empty array in int or tuple of int | |||

Dtype |
Desired output data type. Optional | |||

Order |
'C' for C-style row-major array, 'F' for FORTRAN style column-major array |

In [2]:

```
import numpy as np
x = np.empty([3,2], dtype = int)
print (x)
```

Returns a new array of specified size, filled with zeros.

```
numpy.zeros(shape, dtype = float, order = 'C')
```

Parameter | Description | |||
---|---|---|---|---|

Shape |
Shape of an empty array in int or tuple of int | |||

Dtype |
Desired output data type. Optional | |||

Order |
'C' for C-style row-major array, 'F' for FORTRAN style column-major array |

In [2]:

```
# array of five zeros. Default dtype is float
import numpy as np
x = np.zeros(5)
print (x)
```

In [3]:

```
import numpy as np
x = np.zeros((5,), dtype = np.int)
print (x)
```

In [5]:

```
# custom type
import numpy as np
x = np.zeros((2,2), dtype = [('x', 'i4'), ('y', 'i4')])
print (x)
```

Returns a new array of specified size and type, filled with ones.

```
numpy.ones(shape, dtype = None, order = 'C')
```

Parameter | Description | |||
---|---|---|---|---|

Shape |
Shape of an empty array in int or tuple of int | |||

Dtype |
Desired output data type. Optional | |||

Order |
'C' for C-style row-major array, 'F' for FORTRAN style column-major array |

In [6]:

```
# array of five ones. Default dtype is float
import numpy as np
x = np.ones(5)
print (x)
```

In [7]:

```
import numpy as np
x = np.ones([2,2], dtype = int)
print (x)
```

Dolly Solanki

Simple Guide to Style Display of Pandas DataFrames

Simple Guide to Set Pandas Options to Better Display DataFrames

configparser - Simple Guide to Create and Parse Configuration Files

Simple and Useful Functions of "OS" Module of Python