numpy数据类型

np.dtype({'names':('name', 'age', 'weight'),'formats':('U10', 'i4', 'f8')})
#Output: dtype([('name', '

numpy数据类型_第1张图片

NumPy 还提供np.recarray 类。

input:
name = ['Alice', 'Bob', 'Cathy', 'Doug']
age = [25, 45, 37, 19]
weight = [55.0, 85.5, 68.0, 61.5]
data['name'] = name
data['age'] = age
data['weight'] = weight
data_rec = data.view(np.recarray)        #np.recarry类
data_rec.age                                         #
output:
 array[25, 45, 37, 19]

你可能感兴趣的:(Python编程)