numpy.ndarray.dtype — NumPy v2.6.dev0 Manual

attribute

ndarray.dtype

#

Data-type of the array’s elements.

Warning

Setting arr.dtype is discouraged and may be deprecated in the future. Setting will replace the dtype without modifying the memory (see also

ndarray.view

and

ndarray.astype

).

Parameters:NoneReturns:dnumpy dtype objectExamples

>>> importnumpyasnp>>> x=np.arange(4).reshape((2,2))>>> xarray([[0, 1], [2, 3]])>>> x.dtypedtype('int64') # may vary (OS, bitness)>>> isinstance(x.dtype,np.dtype)True