- dtype() is a python Numpy method that are used to find the data type of the array.
Example-
array is [1 1 2 4]
then arr.dtype return int32
Syntax-
type=np.dtype(array)
program-
#import numpy
import numpy as np
l=[1,2,3,4]
arr=np.array(l)
print("Array isn",arr)
print(arr.dtype)
l=[[1,2,3],[3,2,1],[1,0,1]]
arr=np.array(l)
print("nArray isn",arr)
print(arr.dtype)
l=['a','b','c']
arr=np.array(l)
print("nArray isn",arr)
print(arr.dtype)
Array is
[1 2 3 4]
int32
Array is
[[1 2 3]
[3 2 1]
[1 0 1]]
int32
Array is
['a' 'b' 'c']
<'U1