numpy.core.records.fromrecords
-
numpy.core.records.fromrecords(recList, dtype=None, shape=None, formats=None, names=None, titles=None, aligned=False, byteorder=None)
[source] -
Create a recarray from a list of records in text form.
- Parameters
-
-
recListsequence
-
data in the same field may be heterogeneous - they will be promoted to the highest data type.
-
dtypedata-type, optional
-
valid dtype for all arrays
-
shapeint or tuple of ints, optional
-
shape of each array.
- formats, names, titles, aligned, byteorder :
-
If
dtype
isNone
, these arguments are passed tonumpy.format_parser
to construct a dtype. See that function for detailed documentation.If both
formats
anddtype
are None, then this will auto-detect formats. Use list of tuples rather than list of lists for faster processing.
-
- Returns
-
- np.recarray
-
record array consisting of given recList rows.
Examples
>>> r=np.core.records.fromrecords([(456,'dbe',1.2),(2,'de',1.3)], ... names='col1,col2,col3') >>> print(r[0]) (456, 'dbe', 1.2) >>> r.col1 array([456, 2]) >>> r.col2 array(['dbe', 'de'], dtype='<U3') >>> import pickle >>> pickle.loads(pickle.dumps(r)) rec.array([(456, 'dbe', 1.2), ( 2, 'de', 1.3)], dtype=[('col1', '<i8'), ('col2', '<U3'), ('col3', '<f8')])
© 2005–2020 NumPy Developers
Licensed under the 3-clause BSD License.
https://numpy.org/doc/1.19/reference/generated/numpy.core.records.fromrecords.html