numpy 1.22.4 Pypi GitHub Homepage
Other Docs
AttributesParametersBackRef

Attributes

dtype : dtype

The converted data-type.

After constructing the format_parser object, the dtype attribute is the converted data-type: dtype = format_parser(formats, names, titles).dtype

Parameters

formats : str or list of str

The format description, either specified as a string with comma-separated format descriptions in the form 'f8, i4, a5' , or a list of format description strings in the form ['f8', 'i4', 'a5'] .

names : str or list/tuple of str

The field names, either specified as a comma-separated string in the form 'col1, col2, col3' , or as a list or tuple of strings in the form ['col1', 'col2', 'col3'] . An empty list can be used, in that case default field names ('f0', 'f1', ...) are used.

titles : sequence

Sequence of title strings. An empty list can be used to leave titles out.

aligned : bool, optional

If True, align the fields by padding as the C-compiler would. Default is False.

byteorder : str, optional

If specified, all the fields will be changed to the provided byte-order. Otherwise, the default byte-order is used. For all available string specifiers, see :None:None:`dtype.newbyteorder`.

Class to convert formats, names, titles description to a dtype.

See Also

dtype
sctype2char
typename

Examples

>>> np.format_parser(['<f8', '<i4', '<a5'], ['col1', 'col2', 'col3'],
...  ['T1', 'T2', 'T3']).dtype dtype([(('T1', 'col1'), '<f8'), (('T2', 'col2'), '<i4'), (('T3', 'col3'), 'S5')])

:None:None:`names` and/or :None:None:`titles` can be empty lists. If :None:None:`titles` is an empty list, titles will simply not appear. If :None:None:`names` is empty, default field names will be used.

>>> np.format_parser(['f8', 'i4', 'a5'], ['col1', 'col2', 'col3'],
...  []).dtype dtype([('col1', '<f8'), ('col2', '<i4'), ('col3', '<S5')])
>>> np.format_parser(['<f8', '<i4', '<a5'], [], []).dtype
dtype([('f0', '<f8'), ('f1', '<i4'), ('f2', 'S5')])
See :

Back References

The following pages refer to to this document either explicitly or contain code examples using this.

numpy.rec.fromstring numpy.typing numpy.rec.fromrecords numpy.rec.fromarrays numpy.rec.array numpy.rec.fromfile numpy.recarray

Local connectivity graph

Hover 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


GitHub : /numpy/__init__.py#None
type: <class 'type'>
Commit: