NumPy ndarray.size() Method | Get Number of Elements in NumPy Array Last Updated : 12 Jul, 2025 Comments Improve Suggest changes Like Article Like Report The ndarray.size() method returns the number of elements in the NumPy array. It works the same as np.prod(a.shape), i.e., the product of the dimensions of the array. Example Python3 import numpy as np arr = np.zeros((3, 4, 2), dtype = np.complex128) gfg = arr.size print (gfg) Output : 24Syntax Syntax: numpy.ndarray.size(arr) Parameters arr : [array_like] Input array. Return : [int] The number of elements in the array. How to Find Number of Elements in NumPy ArrayTo find the number of elements in the NumPy array we use ndarray.size() method of the NumPy library in Python. Let us understand it better with an example: Python3 import numpy as geek arr = geek.zeros((3, 4, 2), dtype = geek.complex128) gfg = geek.prod(arr.shape) print (gfg) Output : 24 Comment More infoAdvertise with us Next Article NumPy ndarray.__abs__() | Find Absolute Value of Elements in NumPy Array S sanjoy_62 Follow Improve Article Tags : Machine Learning Python-numpy Python numpy-ndarray python Practice Tags : Machine Learningpython Similar Reads NumPy ndarray.tolist() Method | Convert NumPy Array to List The ndarray.tolist() method converts a NumPy array into a nested Python list. It returns the array as an a.ndim-levels deep nested list of Python scalars. Data items are converted to the nearest compatible built-in Python type. Example Python3 import numpy as np gfg = np.array([1, 2, 3, 4, 5]) print 1 min read NumPy ndarray.tolist() Method | Convert NumPy Array to List The ndarray.tolist() method converts a NumPy array into a nested Python list. It returns the array as an a.ndim-levels deep nested list of Python scalars. Data items are converted to the nearest compatible built-in Python type. Example Python3 import numpy as np gfg = np.array([1, 2, 3, 4, 5]) print 1 min read NumPy ndarray.tolist() Method | Convert NumPy Array to List The ndarray.tolist() method converts a NumPy array into a nested Python list. It returns the array as an a.ndim-levels deep nested list of Python scalars. Data items are converted to the nearest compatible built-in Python type. Example Python3 import numpy as np gfg = np.array([1, 2, 3, 4, 5]) print 1 min read NumPy ndarray.__abs__() | Find Absolute Value of Elements in NumPy Array The ndarray.__abs__() method returns the absolute value of every element in the NumPy array. It is automatically invoked when we use Python's built-in method abs() on a NumPy array. Example Python3 import numpy as np gfg = np.array([1.45, 2.32, 3.98, 4.41, 5.55, 6.12]) print(gfg.__abs__()) Output[ 1 1 min read Get row numbers of NumPy array having element larger than X Let's see how to getting the row numbers of a numpy array that have at least one item is larger than a specified value X. So, for doing this task we will use numpy.where() and numpy.any() functions together. Syntax: numpy.where(condition[, x, y]) Return: [ndarray or tuple of ndarrays] If both x and 2 min read Get row numbers of NumPy array having element larger than X Let's see how to getting the row numbers of a numpy array that have at least one item is larger than a specified value X. So, for doing this task we will use numpy.where() and numpy.any() functions together. Syntax: numpy.where(condition[, x, y]) Return: [ndarray or tuple of ndarrays] If both x and 2 min read Like