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?
# importing NumPy module with an ... true temp_flag = np.any(inputArray) # checking whether the temp_flag is false (Numpy array is empty) if temp_flag == False: # printing empty array, if the condition is true print('Empty NumPy Input Array') else: # else printing NOT ...
๐ŸŒ
w3resource
w3resource.com โ€บ python-exercises โ€บ numpy โ€บ python-numpy-exercise-95.php
NumPy: Check whether the numpy array is empty or not - w3resource
# 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)
๐ŸŒ
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?
If the given array is not empty it returns True; False, otherwise. numpy.any(a, axis=None, out=None, keepdims=<no value>, *, where=<no value>) Consider the below Python program to check NumPy array is empty or not using numpy.any() method.
๐ŸŒ
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 - The easiest and most robust way to check if a numpy 1d, 2d, 3d, or multi-dimensional array is empty using np.ndarray.size attribute.
๐ŸŒ
NumPy
numpy.org โ€บ doc โ€บ 2.1 โ€บ reference โ€บ generated โ€บ numpy.empty.html
numpy.empty โ€” NumPy v2.1 Manual
Array of uninitialized (arbitrary) data of the given shape, dtype, and order. Object arrays will be initialized to None. ... Return an empty array with shape and type of input.
๐ŸŒ
NumPy
numpy.org โ€บ doc โ€บ stable โ€บ reference โ€บ generated โ€บ numpy.empty.html
numpy.empty โ€” NumPy v2.4 Manual
Array of uninitialized (arbitrary) data of the given shape, dtype, and order. Object arrays will be initialized to None. ... Return an empty array with shape and type of input.
๐ŸŒ
Python Pool
pythonpool.com โ€บ home โ€บ blog โ€บ 5 ways to check if the numpy array is empty
5 Ways to Check if the NumPy Array is Empty - Python Pool
January 1, 2024 - We can check if NumPy array is empty in Python using the numpy.size() function, which is essentially used to check the number of elements of the array.
Find elsewhere
๐ŸŒ
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 - To check if a numpy array is empty, 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).
๐ŸŒ
NumPy
numpy.org โ€บ devdocs โ€บ reference โ€บ generated โ€บ numpy.empty.html
numpy.empty โ€” NumPy v2.5.dev0 Manual
Array of uninitialized (arbitrary) data of the given shape, dtype, and order. Object arrays will be initialized to None. ... Return an empty array with shape and type of input.
๐ŸŒ
Python Guides
pythonguides.com โ€บ check-if-numpy-array-is-empty
Check If NumPy Array Is Empty In Python
May 16, 2025 - Let me share a real-world example where checking for empty arrays is crucial. Imagine weโ€™re processing financial transaction data for a US-based retail company: import numpy as np def process_sales_data(daily_transactions): """Process daily sales transactions, skipping days with no data.""" total_revenue = 0 processed_days = 0 for day, transactions in enumerate(daily_transactions, 1): # Skip processing if no transactions for the day if transactions.size == 0: print(f"Day {day}: No transactions recorded, skipping analysis") continue daily_revenue = np.sum(transactions) total_revenue += daily_
๐ŸŒ
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 โ€ฆ
๐ŸŒ
NumPy
numpy.org โ€บ doc โ€บ 1.25 โ€บ reference โ€บ generated โ€บ numpy.empty.html
numpy.empty โ€” NumPy v1.25 Manual
Array of uninitialized (arbitrary) data of the given shape, dtype, and order. Object arrays will be initialized to None. ... Return an empty array with shape and type of input.
๐ŸŒ
Numpywhere
numpywhere.com โ€บ check-if-numpy-array-is-empty.html
Check if Numpy Array is Empty|NumpyWhere
In the above code, arr1 is empty, ... value, so the expression evaluates to False. The np.inf value represents infinity in Numpy. By using the np.isfinite() function, we can check if an array contains infinite values or is empty....
๐ŸŒ
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
๐ŸŒ
NumPy
numpy.org โ€บ doc โ€บ 2.0 โ€บ reference โ€บ generated โ€บ numpy.empty.html
numpy.empty โ€” NumPy v2.0 Manual
Array of uninitialized (arbitrary) data of the given shape, dtype, and order. Object arrays will be initialized to None. ... Return an empty array with shape and type of input.
๐ŸŒ
Enterprise DNA
blog.enterprisedna.co โ€บ python-check-if-list-is-empty-7-methods-explained
Python: Check If List is Empty (7 Methods Explained) โ€“ Master Data Skills + AI
import numpy as np arr = np.array([]) # An empty numpy array if arr.size == 0: print("The numpy array is empty.") else: print("The numpy array is not empty.")
๐ŸŒ
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?
The primary function for creating an uninitialized empty NumPy array is np.empty(). Notice that arr_uninitialized will display seemingly random numbers. These are not zeros; they are whatever values were in the memory segment before NumPy allocated it. # Check the size of arrays print(f"\nSize of arr_uninitialized: {arr_uninitialized.size}") # Output: 6 print(f"Size of arr_zero_elements_1: {arr_zero_elements_1.size}") # Output: 0 print(f"Size of arr_zero_elements_2: {arr_zero_elements_2.size}") # Output: 0 <h1>A function to check if an array has zero elements</h1> <p>def is_array_empty(arr):<br> return arr.size == 0</p>
๐ŸŒ
NumPy
numpy.org โ€บ doc โ€บ 2.2 โ€บ reference โ€บ generated โ€บ numpy.empty.html
numpy.empty โ€” NumPy v2.2 Manual
Array of uninitialized (arbitrary) data of the given shape, dtype, and order. Object arrays will be initialized to None. ... Return an empty array with shape and type of input.