亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

詳解python中Numpy的屬性與創(chuàng)建矩陣

 更新時間:2018年09月10日 08:34:30   投稿:laozhang  
這篇文章給大家分享了關(guān)于python中Numpy的屬性與創(chuàng)建矩陣的相關(guān)知識點內(nèi)容,有興趣的朋友們可以學(xué)習(xí)參考下。

ndarray.ndim:維度

ndarray.shape:形狀

ndarray.size:元素個數(shù)

ndarray.dtype:元素數(shù)據(jù)類型

ndarray.itemsize:字節(jié)大小

創(chuàng)建數(shù)組:

a = np.array([2,23,4]) 
# list 1d
print(a)
# [2 23 4]

指定數(shù)據(jù)類型:

a = np.array([2,23,4],dtype=np.int)
print(a.dtype)
# int 64

dtype可以指定的類型有int32,float,float32,后面不跟數(shù)字默認(rèn)64

a = np.zeros((3,4)) # 數(shù)據(jù)全為0,3行4列
"""

 

a = np.ones((3,4),dtype = np.int)  # 數(shù)據(jù)為1,3行4列
a = np.empty((3,4)) # 數(shù)據(jù)為empty,3行4列

empty類型:初始內(nèi)容隨機(jī),取決于內(nèi)存的狀態(tài)

a = np.arange(10,20,2) # 10-19 的數(shù)據(jù),2步長
a = np.arange(12).reshape((3,4))  # 3行4列,0到11

reshape修改數(shù)據(jù)形狀,如3行4列

a = np.linspace(1,10,20)  # 開始端1,結(jié)束端10,且分割成20個數(shù)據(jù),生成線段

linspace可以確定數(shù)據(jù)的數(shù)量,而arrage不能確定數(shù)據(jù)的數(shù)量,同時,linspace也可以使用reshape定義結(jié)構(gòu)。

相關(guān)文章

最新評論