Each ndarray has an associated data type object (dtype). This data type object (dtype) informs us about the layout of the array. This means it gives us information about:
The ndarray values are stored in a buffer, which can be thought of as a contiguous block of bytes of memory. How these bytes are interpreted is determined by the dtype object.
Parameters:

Exit :
int16
# Python program to create a data type object
# contains a 32bit big endian integer
import
numpy as np
# i4 represents integer a 4 byte number
# & gt; represents big endian byte order and & lt; represents big endian encoding.
# dt is a dtype object
dt
=
np.dtype (
`& gt; i4`
)
print
(
"Byte order is:"
, dt.byteorder)
print
(
"Size is:"
, dt.itemsize)
print
(
"Data type is:"
, dt.name)
Byte order is: & gt; Size is: 4 Name of data type is: int32
The type specifier (i4 in the above case) can take various forms:
Notes:
dtype is different from type.
# Python program to differentiate
# between type and dtype.
import
numpy as np
a
=
np.array ([
1
])
print
(
"type is:" ,
type
(a))
print
(
"dtype is:"
, a.dtype)
Exit:
type is: dtype is: int32

Exit:
(`& lt; f8`, (2,))
# Python program for demonstration
# using a structured array data type object.
< code class = "keyword"> import numpy as np
dt
=
np.dtype ([(
`name`
, np.unicode_,
16
), (
`grades`
, np.float64, (
2
,))])
# x is a structured array with the names and marks of students.
# Data type of student name np.unicode_ and
# mark data type  np.float (64)
x
=
np.array ([(
`Sarah`
, ( 8.0 ,
7.0
)), (
` John`
, (
6.0
,
7.0
))], dtype
=
dt)
print
(x [
1
])
print
(
" Grades of John are: "
, x [
1
] [
`grades`
])
print
(
" Names are: "
, x [
` name`
] )
Output:
(`John`, [6., 7.]) Grades of John are: [6. 7.] Names are: [` Sarah` `John`]
Links:
This article is provided by Ayushi Astana . If you are as Python.Engineering and would like to contribute, you can also write an article using contribute.python.engineering or by posting an article contribute @ python.engineering. See my article appearing on the Python.Engineering homepage and help other geeks.
Please post comments if you find anything wrong or if you`d like to share more information on the topic discussed above.