# Return a new Three-Dimensional array without initializing entries and change the order in Numpy

To return a new Three-Dimensional array, without initializing entries, use the numpy.empty() method in Python Numpy. The 1st parameter is the Shape of the empty array. The order is changed using the "order" parameter. We have set the order to "F" i.e. Fortran-style.

The dtype is the desired output data-type for the array, e.g, numpy.int8. Default is numpy.float64. The order suggests whether to store multi-dimensional data in row-major (C-style) or column-major (Fortran-style) order in memory.

The function empty() returns an array of uninitialized (arbitrary) data of the given shape, dtype, and order. Object arrays will be initialized to None.

NumPy offers comprehensive mathematical functions, random number generators, linear algebra routines, Fourier transforms, and more. It supports a wide range of hardware and computing platforms, and plays well with distributed, GPU, and sparse array libraries

## Steps

At first, import the required library −

import numpy as np

Return a new Three-Dimensional array, without initializing entries using the numpy.empty() method in Python Numpy. The order is changed using the "order" parameter. We have set the order to "F" i.e. Fortran-style −

arr = np.empty([3, 3, 3], order ='F')


Display the array −

print("Array...",arr)

Get the type of the array −

print("Array type...", arr.dtype)


Get the dimensions of the Array −

print("Our Array Dimensions...", arr.ndim)

Get the number of elements in the Array −

print("Number of elements...", arr.size)


## Example

import numpy as np

# To return a new Three-Dimensional array, without initializing entries, use the numpy.empty() method in Python Numpy
# The 1st parameter is the Shape of the empty array
# The order is changed using the "order" parameter
# We have set the order to "F" i.e. Fortran-style
arr = np.empty([3, 3, 3], order ='F')

# Display the array
print("Array...",arr)

# Get the type of the array
print("Array type...", arr.dtype)

# Get the dimensions of the Array
print("Our Array Dimensions...", arr.ndim)

# Get the number of elements in the Array
print("Number of elements...", arr.size)

## Output

Array...
[[[4.67632299e-310 6.90012448e-310 6.89999064e-310]
[6.90012601e-310 6.90012601e-310 6.90012603e-310]
[6.90012435e-310 6.90012602e-310 6.90012603e-310]]

[[0.00000000e+000 6.89999064e-310 6.90012601e-310]
[6.90012602e-310 6.90012601e-310 6.90012600e-310]
[6.89999066e-310 6.90012598e-310 6.90012602e-310]]

[[6.90012601e-310 6.89999064e-310 6.89999064e-310]
[6.90012603e-310 6.89999064e-310 6.89999064e-310]
[6.90012601e-310 6.90012603e-310 1.10670705e-321]]]

Array type...
float64

Our Array Dimensions...
3

Number of elements...
27

Updated on: 10-Feb-2022

109 Views