[Python] Array Attributes of Numpy lib

Attributes of numpy.ndarray:

import numpy as np 

def array():
    a = np.random.random((5,4))
    print(a.shape[0]) #number of rows, 5
    print(a.shape[1]) #number of columns, 4
    print(len(a.shape)) #2
    print(a.size) # 5*4=20
    print(a.dtype) #float64

if __name__ == "__main__":
    #gen_random() 
    array()   

 

posted @ 2017-12-17 23:38  Zhentiw  阅读(222)  评论(0编辑  收藏  举报