NumPy ndarray nbytes() Method Last Updated : 31 Jan, 2024 Comments Improve Suggest changes Like Article Like Report The NumPy ndarray nbytes() function return the total bytes consumed by the elements of the array. NotesIt returns the total bytes consumed by the total element of the array, but it does not calculate memory consumed by non-element attributes of the array object.The size of the data element depends on its attribute.It calculates the total bytes consumed by multiplying the shape of the array and the size of one array element.Syntax Syntax: numpy.ndarray.nbytes(arr) Parameters arr : [array_like] Input array. Return [int] Total bytes consumed by the elements of the array.Examples Let's see an example of how to use ndarray nbytes() method of NumPy library in Python. Example 1 Python3 import numpy as np arr = np.zeros((1, 2, 3), dtype = np.complex128) bytes_consumed = arr.nbytes print (bytes_consumed) Output : 96Example 2 Python3 # Python program explaining # numpy.ndarray.nbytes() function # importing numpy as geek import numpy as geek arr = geek.random.rand(10000, 50) gfg = arr.nbytes print (gfg) Output : 4000000 Comment More infoAdvertise with us Next Article NumPy ndarray nbytes() Method S sanjoy_62 Follow Improve Article Tags : Machine Learning Python-numpy Python numpy-ndarray python Practice Tags : Machine Learningpython Similar Reads numpy.ndarray.ndim() method | Python numpy.ndarray.ndim() function return the number of dimensions of an array. Syntax : numpy.ndarray.ndim(arr) Parameters : arr : [array_like] Input array. If it is not already an ndarray, a conversion is attempted. Return : [int] Return the number of dimensions in arr. Code #1 : Python3 # Python progr 1 min read Numpy - ndarray ndarray is a short form for N-dimensional array which is a important component of NumPy. Itâs allows us to store and manipulate large amounts of data efficiently. All elements in an ndarray must be of same type making it a homogeneous array. This structure supports multiple dimensions which makes it 3 min read numpy.ndarray.itemsize() method | Python numpy.ndarray.itemsize() function return the length of one array element in bytes. Syntax : numpy.ndarray.itemsize(arr) Parameters : arr : [array_like] Input array. Return : [int] The length of one array element in bytes Code #1 : Python3 # Python program explaining # numpy.ndarray.itemsize() functi 1 min read numpy.ndarray.flat() in Python The numpy.ndarray.flat() function is used as a 1_D iterator over N-dimensional arrays. It is not a subclass of, Pythonâs built-in iterator object, otherwise it a numpy.flatiter instance. Syntax : numpy.ndarray.flat() Parameters : index : [tuple(int)] index of the values to iterate Return :  1-D i 3 min read numpy.ndarray.fill() in Python numpy.ndarray.fill() method is used to fill the numpy array with a scalar value. If we have to initialize a numpy array with an identical value then we use numpy.ndarray.fill(). Suppose we have to create a NumPy array a of length n, each element of which is v. Then we use this function as a.fill(v). 2 min read Like