103 viewsJune 1, 2023Python#python 0 Monisha M1.03K June 1, 2023 1 Comment In Python, in what ways can you make an empty NumPy array? Monisha M Posted new comment June 1, 2023 Monisha M commented June 1, 2023 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 0 Answers ActiveVotedNewestOldest Register or Login
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