Open In App

NumPy ndarray.dtype Property | Get Data Type of Elements in Array

Last Updated : 05 Feb, 2024
Improve
Improve
Like Article
Like
Save
Share
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 :

int64

Syntax

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 Elements

To 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

Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads