In this article we will learn how to create an empty NumPy array in Python.
Table Of Contents
 What is an empty Numpy array?
 Create empty NumPy Array using empty() method
 Create empty NumPy Array using arange() method
 Create empty NumPy Array using random() method
 Create empty NumPy Array using np.zeros() method
 Create empty NumPy Array using np.ones() method
 Create empty NumPy Array using np.full() method
 Summary
What is an empty Numpy array?
The size of an empty array is zero, and it does not contain any values.
Example: An empty array
[]
There are multiple ways to create an empty NumPy array in Python. Lets discuss all the methods one by one with proper approach and a working code example.
Create empty NumPy Array using empty() method
The numpy module have an empty() method, and it is used to create empty arrays. This method take the shape and type as arguments and returns a new array of given shape and type, without initializing entries.
Syntax of empty() method
numpy.empty(shape, dtype)
 Parameters:
 shape = Shape of the empty array.
 dtype = Datatype of the array elements.
 Returns:
 Returns a new array of given shape and type, without initializing entries.
Approach:
 Import numpy library
 Pass the shape of array as 0 to the empty() method.
 The empty() method will Returns a new array of given shape.
 print the Array
Source Code
import numpy as np # Creating a empty array arr = np.empty(0) # printing the empty array print(arr) print(arr.size)
Output:
[] 0
Create empty NumPy Array using arange() method
The numpy module has the arange() method,and it is used to create an evenly spaced array within the given range(includnig start and excluding stop). This method take start, stop, step values as arguments and returns evenly spaced values within a given interval. Here the step specifies gap between each element if array.
Now to create an empty array, pass 0 as the argument to the arange() method. This will return a empty array.
Syntax of arange() method
numpy.arange(start, stop, step)
 Parameters:
 start = Start of interval. The interval includes this value. The default start value is 0.
 stop = End of interval. The interval does not include this value.
 step = Spacing between values, default step size is 1.
 Returns:
 Returns evenly spaced values within a given interval.
Approach:
 Import numpy library.
 pass 0 as argument to the arange() method.
 The arange() method will Returns an array of size zero.
 print the Array.
Source Code
import numpy as np # Creating a empty array arr = np.arange(0) # printing the empty array print("array =", arr) print("Size of array =", arr.size)
Output:
array = [] Size of array = 0
Create empty NumPy Array using random() method
The random class of numpy module has a random() method, and it is used to create a random array of given size. It takes size as an argument and returns array with random floats in the halfopen interval [0.0, 1.0). Now to create an empty array, pass 0 as argument to the random() method, this will return a empty array.
Syntax of random() method
numpy.random.random(size)
 Parameters:
 start = Size of the array
 Returns:
 It returns an array with random floats between 0.0 and 1.0
Approach:
 Import numpy library.
 pass 0 as argument to the random() method.
 The random() method will Returns a array of size zero.
 Print the Array.
Source Code
import numpy as np # Creating a empty array arr = np.random.random(0) # printing the empty array print("array =", arr) print("Size of array =", arr.size)
Output:
array = [] Size of array = 0
Create empty NumPy Array using np.zeros() method
The numpy module has the zeros() method, and it is used to create array with elements as zeros. This method takes shape and type as arguments and returns array filled with zeros. Now to create an empty array, pass 0 as argument to the zeros() method, this will return a empty array.
Syntax of zeros() method
numpy.zeros(shape, dtype)
 Parameters:
 shape = Shape of the empty array.
 dtype = Datatype of the array elements.
 Returns:
 It Returns a new array of zeros with given shape and type.
Approach:
 Import numpy library.
 pass 0 as argument to the zeros() method.
 The zeros() method will Returns a array of size zero.
 Print the Array.
Source Code
import numpy as np # Creating a empty array arr = np.zeros(0) # Printing the empty array print("array =",arr) print("Size of array =",arr.size)
Output:
array = [] Size of array = 0
Create empty NumPy Array using np.ones() method
The numpy module has the ones() method, and it is used to create array with elements as ones. This method takes shape and type as arguments and returns array filled with ones. Now to create an empty array, pass 0 as argument to the ones() method, this will return a empty array.
Syntax of ones() method
numpy.ones(shape, dtype)
 Parameters:
 shape = Shape of the empty array.
 dtype = Datatype of the array elements.
 Returns:
 Returns a new array of ones with given shape and type.
Approach:
 Import numpy library
 pass 0 as argument to the ones() method.
 The ones() method will Returns a array of size zero.
 print the Array
Source Code
import numpy as np # Creating a empty array arr = np.ones(0) # printing the empty array print("array =",arr) print("Size of array =",arr.size)
Output:
array = [] Size of array = 0
Create empty NumPy Array using np.full() method
The numpy module has the full() method, and it is used to create array with given shape and element. This method takes shape and fill value as arguments and returns array filled with fill value. Now to create an empty array, pass 0 as shape and 0 as fill value to the full() method, this will return a empty array.
Syntax of full() method
numpy.full(shape, flll)
 Parameters:
 shape = Shape of the empty array.
 fill = Value to be filled in array.
 Returns:
 Return a new array of given shape and type, filled with fill_value.
Approach:
 Import numpy library
 pass 0,0 as argument to the full() method.
 The full() method will Returns a array of size zero.
 print the Array
Source Code
import numpy as np # Creating a empty array arr = np.full(0,0) # printing the empty array print("array =",arr) print("Size of array =",arr.size)
Output:
array = [] Size of array = 0
Summary
Great! you made it. We have discussed all possible methods to Create an empty numpy array using Python. Happy learning.
Pandas Tutorials Learn Data Analysis with Python

Pandas Tutorial Part #1  Introduction to Data Analysis with Python

Pandas Tutorial Part #2  Basics of Pandas Series

Pandas Tutorial Part #3  Get & Set Series values

Pandas Tutorial Part #4  Attributes & methods of Pandas Series

Pandas Tutorial Part #5  Add or Remove Pandas Series elements

Pandas Tutorial Part #6  Introduction to DataFrame

Pandas Tutorial Part #7  DataFrame.loc[]  Select Rows / Columns by Indexing

Pandas Tutorial Part #8  DataFrame.iloc[]  Select Rows / Columns by Label Names

Pandas Tutorial Part #9  Filter DataFrame Rows

Pandas Tutorial Part #10  Add/Remove DataFrame Rows & Columns

Pandas Tutorial Part #11  DataFrame attributes & methods

Pandas Tutorial Part #12  Handling Missing Data or NaN values

Pandas Tutorial Part #13  Iterate over Rows & Columns of DataFrame

Pandas Tutorial Part #14  Sorting DataFrame by Rows or Columns

Pandas Tutorial Part #15  Merging or Concatenating DataFrames

Pandas Tutorial Part #16  DataFrame GroupBy explained with examples
Are you looking to make a career in Data Science with Python?
Data Science is the future, and the future is here now. Data Scientists are now the most soughtafter professionals today. To become a good Data Scientist or to make a career switch in Data Science one must possess the right skill set. We have curated a list of Best Professional Certificate in Data Science with Python. These courses will teach you the programming tools for Data Science like Pandas, NumPy, Matplotlib, Seaborn and how to use these libraries to implement Machine learning models.
Checkout the Detailed Review of Best Professional Certificate in Data Science with Python.
Remember, Data Science requires a lot of patience, persistence, and practice. So, start learning today.