数组Ndarray 对象
numpy.array(object, dtype = None, copy = True, order = None, subok = False, ndmin = 0)
- object为数组或嵌套的数列
- dtype 数组元素的数据类型,可选
- copy 对象是否需要复制,可选
- order 创建数组的样式,C为行方向,F为列方向,A为任意方向(默认)
- subok 默认返回一个与基类类型一致的数组
- ndmin 指定生成数组的最小维度
实例:
np.array(range(0,10),dtype=int,ndmin=2)
#Out[92]: array([[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]])
>>> a = np.array([1, 2, 3], dtype = complex)
>>> print (a)
[1.+0.j 2.+0.j 3.+0.j]
数据类型dtype
>>> # 使用标量类型
... dt = np.dtype(np.int32)
>>> print(dt)
int32
>>> # int8, int16, int32, int64 四种数据类型可以使用字符串 'i1', 'i2','i4','i8' 代替
... dt = np.dtype('i4')
>>&