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
More Related Contents:
- String concatenation of two pandas columns
- Intuition and idea behind reshaping 4D array to 2D array in NumPy
- Find column name in pandas that matches an array
- Reshape an array in NumPy
- binning data in python with scipy/numpy
- How do I count the occurrence of a certain item in an ndarray?
- Transform a set of numbers in numpy so that each number gets converted into a number of other numbers which are less than it
- Calculating Pearson correlation and significance in Python
- ValueError: could not broadcast input array from shape (224,224,3) into shape (224,224)
- how to read certain columns from Excel using Pandas – Python
- How do I load a caffe model and convert to a numpy array?
- Why does numpy.linalg.solve() offer more precise matrix inversions than numpy.linalg.inv()?
- How to calculate cumulative normal distribution?
- load csv into 2D matrix with numpy for plotting
- Pandas in AWS lambda gives numpy error
- Create numpy matrix filled with NaNs
- How to fix ‘Object arrays cannot be loaded when allow_pickle=False’ for imdb.load_data() function?
- Filling in date gaps in MultiIndex Pandas Dataframe
- Shuffling NumPy array along a given axis
- How to display progress of scipy.optimize function?
- Fitting a Weibull distribution using Scipy
- Numpy shuffle multidimensional array by row only, keep column order unchanged
- How to resample a dataframe with different functions applied to each column?
- Converting 2D Numpy array of grayscale values to a PIL image
- Numpy array broadcasting rules
- Convert a column of timestamps into periods in pandas
- Elegant way to perform tuple arithmetic
- Why can’t I raise to a negative power in numpy?
- Generate random array of floats between a range
- Understanding scipy deconvolve