This is a pre-release version (2.5.0.dev0+git20251130.2de293a).Go to latest (2.4.4)
{ } Raw JSON

bundles / numpy 2.5.0.dev0+git20251130.2de293a / numpy / rec / fromarrays

function

numpy.rec:fromarrays

source: build-install/usr/lib/python3.14/site-packages/numpy/_core/records.py:568

Signature

def fromarrays(arrayList, dtype = None, shape = None, formats = None, names = None, titles = None, aligned = False, byteorder = None)

Summary

Create a record array from a (flat) list of arrays

Parameters

arrayList : list or tuple

List of array-like objects (such as lists, tuples, and ndarrays).

dtype : data-type, optional

valid dtype for all arrays

shape : int or tuple of ints, optional

Shape of the resulting array. If not provided, inferred from arrayList[0].

formats, names, titles, aligned, byteorder

If dtype is None, these arguments are passed to numpy.rec.format_parser to construct a dtype. See that function for detailed documentation.

Returns

: np.recarray

Record array consisting of given arrayList columns.

Examples

x1=np.array([1,2,3,4])
x2=np.array(['a','dd','xyz','12'])
x3=np.array([1.1,2,3,4])
r = np.rec.fromarrays([x1,x2,x3],names='a,b,c')
✓
print(r[1])
✗
(2, 'dd', 2.0)
x1[1]=34
r.a
✓
array([1, 2, 3, 4])
x1 = np.array([1, 2, 3, 4])
x2 = np.array(['a', 'dd', 'xyz', '12'])
x3 = np.array([1.1, 2, 3,4])
r = np.rec.fromarrays(
    [x1, x2, x3],
    dtype=np.dtype([('a', np.int32), ('b', 'S3'), ('c', np.float32)]))
r
✓
rec.array([(1, b'a', 1.1), (2, b'dd', 2. ), (3, b'xyz', 3. ),
           (4, b'12', 4. )],
          dtype=[('a', '<i4'), ('b', 'S3'), ('c', '<f4')])

Aliases

  • numpy.rec.fromarrays