首页 > 其他 > 详细

numpy的基本操作

时间:2019-09-22 13:21:39      阅读:103      评论:0      收藏:0      [点我收藏+]

np.concatenate, axis =0,在0维度进行拼接,且除0维度为array的shape必须相同

np.sum,axis =0, 其他的维度的维数不变,累加0维度 

 

array的indexing:

基本形式:arr[object], object可以是integer, slicing,boolean array, integer array

1 x = np.array([[1, 2], [3, 4], [5, 6]])
2 x[[0, 1, 2], [0, 1, 0]]           #返回一个一维array
1 >>> x = np.array([[1., 2.], [np.nan, 3.], [np.nan, np.nan]])
2 >>> x[~np.isnan(x)]                # x[~np.isnan(x)]返回的是一个相同shape的array
3 array([ 1.,  2.,  3.])             # 返回一个一位array

 

ellipsis:

 ... [??l?ps?s] 省略

for a 3d array, a[...,0] is the same as a[:,:,0] and for 4d, a[:,:,:,0], similarly, a[0,...,0] is a[0,:,:,0]

 

 

 

numpy.arange([start]stop[step]dtype=None)

numpy.linspace(startstopnum=50endpoint=Trueretstep=Falsedtype=Noneaxis=0) :

返回间隔相同的数,默认endpoint为true,为false时,不包含stop

 

 

ndarray:

https://www.tutorialspoint.com/numpy/numpy_data_types.htm

float32 float64  int32 int 64 uint32 uint64

numpy的基本操作

原文:https://www.cnblogs.com/flipped415/p/11566533.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!