numpy.dtype.fields#

attribute

dtype.fields#

Dictionary of named fields defined for this data type, orNone.

The dictionary is indexed by keys that are the names of the fields.Each entry in the dictionary is a tuple fully describing the field:

(dtype,offset[,title])

Offset is limited to C int, which is signed and usually 32 bits.If present, the optional title can be any object (if it is a stringor unicode then it will also be a key in the fields dictionary,otherwise it’s meta-data). Notice also that the first two elementsof the tuple can be passed directly as arguments to thendarray.getfield andndarray.setfield methods.

Examples

>>>importnumpyasnp>>>dt=np.dtype([('name',np.str_,16),('grades',np.float64,(2,))])>>>print(dt.fields){'name': (dtype('<U16'), 0), 'grades': (dtype(('<f8', (2,))), 64)}
On this page