You can always take a look at the .size attribute. It is defined as an integer, and is zero (0) when there are no elements in the array:

import numpy as np
a = np.array([])

if a.size == 0:
    # Do something when `a` is empty
Answer from JoshAdel on Stack Overflow
🌐
TutorialsPoint
tutorialspoint.com › what-is-the-preferred-method-to-check-for-an-empty-array-in-numpy
What is the preferred method to check for an empty array in NumPy?
October 20, 2022 - This can be used to see if the array is empty. The following program returns whether the given NumPy array is empty or not using the shape attribute ? import numpy as np # creating a numpy array inputArray = np.array([]) # checking whether the shape of the array is equal to 0 (Empty array condition) if inputArray.shape[0] == 0: # prining empty array if condition is true print("Empty input array") else: # else printing not Empty array print('Input array is NOT empty')
Discussions

Deprecate truth-testing on empty arrays
I tested the waters with this on the numpy-discussion newsgroup earlier this week yesterday, and the general response seemed to be that this is actionable, so I am making an issue for further discu... More on github.com
🌐 github.com
13
August 19, 2017
How can I create a truly empty numpy array which can be merged onto (by a recursive function)?
I can't say I fully followed your problem statement, but you can create an array with a total size of zero if any of the dimensions has size zero: a = np.empty((0, 3)) # Doesn't really matter if you use `empty`, `zeros` or `ones` here Zero-size arrays are the neutral element wrt. concatenation along their zero-size dimension (if that's what you mean by "merging"): b = np.random.uniform(size=(20, 3)) c = np.concatenate([a, b], 0) (c == b).all() # True More on reddit.com
🌐 r/learnpython
2
2
June 20, 2023
Is it possible to grab the last element of a numpy array with a negative slice?
You can't loop from negative to postive slice values as they don't "wrap". a[-2:2] would also give an empty array. More on reddit.com
🌐 r/learnpython
8
1
December 15, 2021
Why does numpy.empty put numbers on the order of 1^9 or 1^(-300) in the array?
It's allocating the memory without initializing. The memory contains whatever was already there, which could be bits of a program or a string or anything at all. Interpreting those random bit patterns as numbers, it's not surprising they might happen to correspond to very large or very small exponents. So it's not "using" any values. That's just the numeric value that's displayed when the array element happened to be the 47,042-th pixel in the picture of somebody's cat. More on reddit.com
🌐 r/learnpython
6
1
August 4, 2022
🌐
w3resource
w3resource.com › python-exercises › numpy › python-numpy-exercise-95.php
NumPy: Check whether the numpy array is empty or not - w3resource
August 29, 2025 - # Importing the NumPy library and aliasing it as 'np' import numpy as np # Creating a NumPy array 'x' containing integers [2, 3] x = np.array([2, 3]) # Creating an empty NumPy array 'y' y = np.array([]) # Printing the size of array 'x' # As 'x' contains 2 elements, its size is 2 print(x.size) # Printing the size of array 'y' # 'y' is an empty array, so its size is 0 print(y.size) ... print(x.size): Print the size of array 'x' using the size attribute.
🌐
NumPy
numpy.org › doc › 1.25 › reference › generated › numpy.empty.html
numpy.empty — NumPy v1.25 Manual
Return an empty array with shape and type of input. ... Return a new array setting values to one. ... Return a new array setting values to zero.
🌐
IncludeHelp
includehelp.com › python › how-to-check-whether-a-numpy-array-is-empty-or-not.aspx
How to check whether a NumPy array is empty or not?
May 26, 2023 - To check an empty NumPy array, there are multiple methods that you can use such as numpy.ndarray.size attribute, numpy.any() method, and numpy.size() method. Let's discuss all these methods with examples. The ndarray.size attribute returns the total number of elements in a NumPy array.
🌐
NumPy
numpy.org › doc › 2.3 › reference › generated › numpy.empty.html
numpy.empty — NumPy v2.3 Manual
For reproducible behavior, be sure to set each element of the array before reading. ... Try it in your browser! >>> import numpy as np >>> np.empty([2, 2]) array([[ -9.74499359e+001, 6.69583040e-309], [ 2.13182611e-314, 3.06959433e-309]]) #uninitialized
🌐
GeeksforGeeks
geeksforgeeks.org › numpy › python-numpy
Python NumPy - GeeksforGeeks
The number of dimensions is called the rank and the size along each dimension is called the shape. In NumPy, arrays are called ndarray and elements are accessed using square brackets [], often created from nested Python lists.
Published   2 weeks ago
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-check-if-list-empty-not
Check if a list is empty or not in Python - GeeksforGeeks
October 24, 2024 - NumPy · Pandas · Practice · ... empty with simple examples. The simplest way to check if a list is empty is by using Python's not operator. The not operator is the simplest way to see if a list is empty....
Find elsewhere
🌐
Verve AI
vervecopilot.com › interview-questions › why-is-understanding-an-empty-numpy-array-crucial-for-your-next-technical-interview
Why Is Understanding An Empty Numpy Array Crucial For Your Next Technical Interview?
Before performing any aggregations (sum, mean, max) or indexing on a NumPy array, especially if it's user-provided or dynamically generated, always check its .size attribute. This simple check prevents runtime errors and shows your commitment to writing robust code [4]. When discussing array initialization, clearly explain that np.empty() is for uninitialized memory and is faster, while np.zeros() explicitly fills with zeros [2]. Be prepared to discuss scenarios where one might be preferred over the other (e.g., pre-allocating for iterative filling vs.
🌐
NumPy
numpy.org › doc › 2.3 › user › absolute_beginners.html
NumPy: the absolute basics for beginners — NumPy v2.3 Manual
If the element you’re looking for doesn’t exist in the array, then the returned array of indices will be empty.
🌐
Medium
panjeh.medium.com › check-whether-a-numpy-array-is-empty-or-not-2d6011eac9
Check whether a numpy array is empty or not? - Panjeh - Medium
April 22, 2021 - Check whether a numpy array is empty or not? Numpy array has .size attribute. If it returns zero it means there are no elements in the array. Suppose A is a numpy array. if A.size == 0: # then A …
🌐
W3Schools
w3schools.com › python › numpy › numpy_array_filter.asp
NumPy Filter Array
The above example is quite a common task in NumPy and NumPy provides a nice way to tackle it. We can directly substitute the array instead of the iterable variable in our condition and it will work just as we expect it to. Create a filter array that will return only values higher than 42: import numpy as np arr = np.array([41, 42, 43, 44]) filter_arr = arr > 42 newarr = arr[filter_arr] print(filter_arr) print(newarr) Try it Yourself »
🌐
Quora
quora.com › How-do-I-check-if-an-array-is-empty-in-Python
How to check if an array is empty in Python - Quora
Answer (1 of 12): I am going to assume you are talking about lists (Python does have arrays, but they are very different to lists). Three ways : 1 Test the truthiness If you know the item is a list you do : [code]if not my_list: print(‘List is empty’) [/code]Empty containers (lists,sets,t...
🌐
Python Guides
pythonguides.com › check-if-an-array-is-empty-in-python
How To Check If An Array Is Empty In Python?
March 19, 2025 - You can use the size the attribute of a NumPy array to determine if it is empty.
🌐
w3resource
w3resource.com.cach3.com › python-exercises › numpy › python-numpy-exercise-95.php.html
NumPy: Check whether the numpy array is empty or not - w3resource
May 28, 2022 - import numpy as np x = np.array([2, 3]) y = np.array([]) # size 2, array is not empty print(x.size) # size 0, array is empty print(y.size) ... Have another way to solve this solution? Contribute your code (and comments) through Disqus. Previous: Write a NumPy program to count the frequency of unique values in numpy array. Next: Write a NumPy program to divide each row by a vector element. ... Test your Programming skills with w3resource's quiz.  ... (Note that the incantation above won't work if you've already used os.chdir() to change your current working directory, since the value of the __file__ constant is relative to the current working directory and is not changed by an os.chdir() call.)
🌐
Data Science Parichay
datascienceparichay.com › home › blog › how to check if a numpy array is empty?
How to Check if a Numpy Array is Empty? - Data Science Parichay
November 28, 2022 - Use the array’s .size attribute and check if it’s equal to 0 (an array’s size is zero if it has no elements). Use the array’s .shape attribute which returns the shape of a numpy array. If the array is empty, the first value in the returned tuple would be 0.
🌐
GitHub
github.com › numpy › numpy › issues › 9583
Deprecate truth-testing on empty arrays · Issue #9583 · numpy/numpy
August 19, 2017 - I tested the waters with this on the numpy-discussion newsgroup earlier this week yesterday, and the general response seemed to be that this is actionable, so I am making an issue for further discussion. The long and short is that truth-...
Published   Aug 19, 2017
🌐
Appdividend
appdividend.com › create-and-check-if-a-numpy-array-is-empty
How to Create and Check If a Numpy Array is Empty
July 10, 2025 - import numpy as np arr3d = np.empty((2, 0, 4)) # 2 rows 0 columns 4 depth print(arr3d) print(arr3d.size) print(arr3d.shape) # Output: # [] # 0 # (2, 0, 4) The most Pythonic way to check if an array is empty is to use the .size attribute.
🌐
Educative
educative.io › answers › how-to-create-an-empty-numpy-array
How to create an empty NumPy array
numpy.zeros(shape, dtype=float, order='C') numpy.empty(shape, dtype=float, order='C') # Shape -> Shape of the new array, e.g., (2, 3) or 2. # dtype -> The desired data-type for the array,e.g., numpy.int8. Default is numpy.float64. This parameter is optional. # order -> Indicates whether multi-dimensional data should be stored in row-major (C-style) or column-major (Fortran-style) order in memory.