bundles / numpy 2.4.4 / numpy / rec / format_parser
class
numpy.rec:format_parser
source: /numpy/rec/__init__.py
Signature
class format_parser ( formats , names , titles , aligned = False , byteorder = None ) Summary
Class to convert formats, names, titles description to a dtype.
Extended Summary
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 strThe format description, either specified as a string with comma-separated format descriptions in the form
'f8, i4, S5', or a list of format description strings in the form['f8', 'i4', 'S5'].names: str or list/tuple of strThe 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: sequenceSequence of title strings. An empty list can be used to leave titles out.
aligned: bool, optionalIf True, align the fields by padding as the C-compiler would. Default is False.
byteorder: str, optionalIf 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
dtype.newbyteorder.
Attributes
dtype: dtypeThe converted data-type.
Examples
import numpy as np np.rec.format_parser(['<f8', '<i4'], ['col1', 'col2'], ['T1', 'T2']).dtype✓
np.rec.format_parser(['f8', 'i4', 'a5'], ['col1', 'col2', 'col3'], []).dtype✗
np.rec.format_parser(['<f8', '<i4', '<a5'], [], []).dtype
✓See also
Aliases
-
numpy.rec.format_parser