0

In Python, in what ways can you make an empty NumPy array?

Monisha M Posted new comment June 1, 2023
User Avatar

In Python, there are two ways to build an empty array:

Code

import numpy
#method 1
array_1 = numpy.array([])
print(array_1)
#method 2
array_2 = numpy.empty(shape=(3,3))
print(array_2)
Output:
[[9.03420200e-308 7.54982336e-308 0.00000000e+000]
[0.00000000e+000 0.00000000e+000 0.00000000e+000]
[0.00000000e+000 0.00000000e+000 1.2095