dtype(dtype, align=False, copy=False)
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.
Object to be converted to a data type object.
Add padding to the fields to match what a C compiler would output for a similar C-struct. Can be True
only if :None:None:`obj` is a dictionary or a comma-separated string. If a struct dtype is being created, this also sets a sticky alignment flag isalignedstruct
.
Make a new copy of the data-type object. If False
, the result may just be a reference to a built-in data-type object.
Create a data type object.
Using array-scalar type:
>>> np.dtype(np.int16) dtype('int16')
Structured type, one field name 'f1', containing int16:
>>> np.dtype([('f1', np.int16)]) dtype([('f1', '<i2')])
Structured type, one field named 'f1', in itself containing a structured type with one field:
>>> np.dtype([('f1', [('f1', np.int16)])]) dtype([('f1', [('f1', '<i2')])])
Structured type, two fields: the first field contains an unsigned int, the second an int32:
>>> np.dtype([('f1', np.uint64), ('f2', np.int32)]) dtype([('f1', '<u8'), ('f2', '<i4')])
Using array-protocol type strings:
>>> np.dtype([('a','f8'),('b','S10')]) dtype([('a', '<f8'), ('b', 'S10')])
Using comma-separated field formats. The shape is (2,3):
>>> np.dtype("i4, (2,3)f8") dtype([('f0', '<i4'), ('f1', '<f8', (2, 3))])
Using tuples. int
is a fixed type, 3 the field's shape. void
is a flexible type, here of size 10:
>>> np.dtype([('hello',(np.int64,3)),('world',np.void,10)]) dtype([('hello', '<i8', (3,)), ('world', 'V10')])
Subdivide int16
into 2 int8
's, called x and y. 0 and 1 are the offsets in bytes:
>>> np.dtype((np.int16, {'x':(np.int8,0), 'y':(np.int8,1)})) dtype((numpy.int16, [('x', 'i1'), ('y', 'i1')]))
Using dictionaries. Two fields named 'gender' and 'age':
>>> np.dtype({'names':['gender','age'], 'formats':['S1',np.uint8]}) dtype([('gender', 'S1'), ('age', 'u1')])
Offsets in bytes, here 0 and 25:
>>> np.dtype({'surname':('S25',0),'age':(np.uint8,25)}) dtype([('surname', 'S25'), ('age', 'u1')])See :
The following pages refer to to this document either explicitly or contain code examples using this.
numpy.common_typenumpy.ascontiguousarraynumpy.issubdtypenumpy.asarraynumpy.nanstdnumpy.rec.arraynumpy.memmapnumpy.meannumpy.lib.format.descr_to_dtypenumpy.nanmeannumpy.rec.fromstringnumpy.find_common_typenumpy.result_typenumpy.nancumsumnumpy.core._multiarray_umath.min_scalar_typenumpy.geomspacenumpy.ma.core.make_masknumpy.rec.fromrecordsnumpy.promote_typesnumpy.fromstringnumpy.ma.core._recursive_fill_valuenumpy.ma.core.MaskedArraynumpy.lib.format.dtype_to_descrnumpy.logspacenumpy.stdnumpy.lib._iotools.easy_dtypenumpy.arraynumpy.core.multiarray.scalarnumpy.ma.core.arraynumpy.rec.fromarraysnumpy.linspacenumpy.arangenumpy.lib._iotools.StringConverternumpy.fromregexnumpy.mintypecodenumpy.fromfunctionnumpy.core._multiarray_umath.can_castnumpy.core._multiarray_umath.result_typenumpy.ma.core.MaskedArray.viewnumpy.lib._iotools.StringConverter.updatenumpy.lib.npyio.recfromcsvnumpy.ma.extras.masked_allnumpy.min_scalar_typenumpy.maximum_sctypenumpy.ndarraynumpy.asfarraynumpy.typenamenumpy.format_parsernumpy.lib.npyio.recfromtxtnumpy.can_castnumpy.ma.core.choosenumpy.lib.format.open_memmapnumpy.rec.fromfilenumpy.recarraynumpy.ma.core.make_mask_nonenumpy.cumsumpandas.core.dtypes.cast.maybe_infer_dtype_typepandas.core.generic.NDFrame.convert_dtypespandas.core.dtypes.common.is_timedelta64_ns_dtypepandas.core.dtypes.missing.na_value_for_dtypepandas.core.arrays.sparse.array.SparseArray.astypepandas.core.construction.arraypandas.core.dtypes.dtypes.PandasDtypeHover to see nodes names; edges to Self not shown, Caped at 50 nodes.
Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)
SVG is more flexible but power hungry; and does not scale well to 50 + nodes.
All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them