python fromarray_Python numpy.core.records.fromarrays函数方法的使用

numpy.core.records.fromarrays

numpy.core.records.fromarrays(arrayList, dtype=None, shape=None, formats=None, names=None, titles=None, aligned=False, byteorder=None)[source]

从(flat)数组列表创建记录数组参数 :arrayList :list 或 tuple

类数组对象的列表(例如,列表,元组和ndarray)。

dtype :data-type, 可选

所有数组的有效dtype

shape :int 或 ints的tuple, 可选

所得数组的Shape。 如果未提供,则从arrayList [0]推断。

formats, names, titles, aligned, byteorder:

如果dtype为None,

则将这些参数传递给numpy.format_parser以构造dtype。

有关详细文档,请参见该功能。

返回值 :np.recarray

记录由给定的arrayList列组成的数组。

例子>>> x1=np.array([1,2,3,4])

>>> x2=np.array(['a','dd','xyz','12'])

>>> x3=np.array([1.1,2,3,4])

>>> r = np.core.records.fromarrays([x1,x2,x3],names='a,b,c')

>>> print(r[1])

(2, 'dd', 2.0) # may vary

>>> 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.core.records.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', '

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值