bundles / numpy 2.4.3 / numpy / dtype
_DTypeMeta
numpy:dtype
source: /numpy/__init__.py
Summary
Create a data type object.
Extended Summary
A numpy array is homogeneous, and contains elements described by a dtype object. A dtype object can be constructed from different combinations of fundamental numeric types.
Parameters
dtypeObject to be converted to a data type object.
align: bool, optionalAdd padding to the fields to match what a C compiler would output for a similar C-struct. Can be
Trueonly ifobjis a dictionary or a comma-separated string. If a struct dtype is being created, this also sets a sticky alignment flagisalignedstruct.copy: bool, optionalMake a new copy of the data-type object. If
False, the result may just be a reference to a built-in data-type object.metadata: dict, optionalAn optional dictionary with dtype metadata.
Examples
Using array-scalar type:import numpy as np np.dtype(np.int16)✓
np.dtype([('f1', np.int16)])
✓np.dtype([('f1', [('f1', np.int16)])])
✓np.dtype([('f1', np.uint64), ('f2', np.int32)])
✓np.dtype([('a','f8'),('b','S10')])
✓np.dtype("i4, (2,3)f8")
✓np.dtype([('hello',(np.int64,3)),('world',np.void,10)])
✓np.dtype((np.int16, {'x':(np.int8,0), 'y':(np.int8,1)}))
✓np.dtype({'names':['gender','age'], 'formats':['S1',np.uint8]})
✓np.dtype({'surname':('S25',0),'age':(np.uint8,25)})
✓See also
- result_type
Aliases
-
numpy.dtype
Referenced by
This package
- reference:arrays.dtypes
- user:basics.io.genfromtxt
- user:basics.rec
- user:basics.types
- numpy.lib.format:dtype_to_descr
- reference:arrays.dtypes
- user:basics.io.genfromtxt
- user:basics.rec
- user:basics.types
- numpy.lib.format:dtype_to_descr
- reference:arrays.dtypes
- user:basics.io.genfromtxt
- user:basics.rec
- user:basics.types
- numpy.lib.format:dtype_to_descr