NumPy ndarray.dtype Property | Get Data Type of Elements in Array Last Updated : 05 Feb, 2024 Comments Improve Suggest changes Like Article Like Report The ndarray.dtype attribute returns the data type of the array’s elements. This attribute is read-only and cannot be modified directly. Example Python3 import numpy as geek arr = geek.array([[0, 1], [2, 3]]) gfg = arr.dtype print (gfg) Output : int64Syntax Syntax: numpy.ndarray.dtype Parameters : None Return : [numpy dtype object] Return the data-type of the array’s elements. How to check the Data Type of NumPy Array ElementsTo check the data type of NumPy array elements we use ndarray.dtype attribute of the NumPy library in Python Let us look at the example to understand it better. Python3 import numpy as geek arr = geek.array([ 0., 1., 2.]) gfg = arr.dtype print (gfg) Output : float64 Comment More infoAdvertise with us Next Article NumPy ndarray.dtype Property | Get Data Type of Elements in Array sanjoy_62 Follow Improve Article Tags : Python Python-numpy Python numpy-ndarray Practice Tags : python Similar Reads NumPy ndarray.byteswap() Method | Swap bytes of the Array Elements The ndarray.byteswap() method swaps the bytes of the array elements. It toggles between low-endian and big-endian data representation by returning a byteswapped array, optionally swapped in-place. Note: byteswap() method does not work on arrays of strings. ExamplePython3 # Python program explaining 2 min read NumPy ndarray.size() Method | Get Number of Elements in NumPy Array 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 Synta 1 min read NumPy ndarray.T | Get View of Transposed Array The NumPy ndarray.T attribute finds the view of the transposed Array. It can transpose any array having a dimension greater than or equal to 2. It works similarly to the numpy.transpose() method but it is easy and concise to use. SyntaxSyntax: ndarray.T Returns Transpose of given arrayExamplesLet's 1 min read Find the length of each string element in the Numpy array NumPy builds on (and is a successor to) the successful Numeric array object. Its goal is to create the corner-stone for a useful environment for scientific computing. NumPy provides two fundamental objects: an N-dimensional array object (ndarray) and a universal function object (ufunc). In this post 3 min read Using NumPy to Convert Array Elements to Float Type There are often when we must convert an array in Python to a differing type. One of these times would be when given an array and having to convert it to an array of float types. This is often useful when conducting data analysis and there are a variety of ways of doing this. Whilst iterating through 5 min read Data type Object (dtype) in NumPy Python Every ndarray has an associated data type (dtype) object. This data type object (dtype) informs us about the layout of the array. This means it gives us information about: Type of the data (integer, float, Python object, etc.)Size of the data (number of bytes)The byte order of the data (little-endia 3 min read Change the Data Type of the Given NumPy Array NumPy arrays are homogenous, meaning all elements in a NumPy array are of the same data type and referred to as array type. You might want to change the data type of the NumPy array to perform some specific operations on the entire data set. In this tutorial, we are going to see how to change the d 4 min read NumPy ndarray.transpose() Method | Find Transpose of the NumPy Array The ndarray.transpose() function returns a view of the array with axes transposed. For a 1-D array, this has no effect, as a transposed vector is simply the same vector.For a 2-D array, this is a standard matrix transpose.For an n-D array, if axes are given, their order indicates how the axes are pe 2 min read Python | dtype object length of Numpy array of strings In this post, we are going to see the datatype of the numpy object when the underlying data is of string type. In numpy, if the underlying data type of the given object is string then the dtype of object is the length of the longest string in the array. This is so because we cannot create variable l 3 min read NumPy ndarray.imag() Method | Get Imaginary Part in NumPy Array The ndarray.imag() method returns the imaginary part of the complex number in the NumPy array. Note: Remember resulting data type for the imaginary value is 'float64'. Example Python3 # import the important module in python import numpy as np # make an array with numpy gfg = np.array([1 + 2j, 2 + 3j 1 min read Like