NumPy学习2:创建数组

  1.使用array创建数组

b = array([2, 3, 4])
print b
print b.dtype


2.把序列转化为数组
b = array( [ (1.5,2,3), (4,5,6) ] )
print b

3.函数 function 创建一个全是0的数组,函数 ones 创建一个全1的数组,函数empty 创建一个内容随机并且依赖与内存状态的数组。默认创建的数组类型(dtype)都是float64。
a=zeros( (3,4) )
print a

b=ones( (2,3,4), dtype= numpy.int8 )
print b

c= numpy.empty((2, 3))
print c

b=arange( 10, 30, 5 )
返回的是numpy.ndarray


转载于:https://www.cnblogs.com/zijiyanxi/p/6128807.html

你可能感兴趣的:(NumPy学习2:创建数组)