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
(start, stop, num=50, endpoint=True, retstep=False, dtype=None, axis=0) :
返回间隔相同的数,默认endpoint为true,为false时,不包含stop
ndarray:
https://www.tutorialspoint.com/numpy/numpy_data_types.htm
float32 float64 int32 int 64 uint32 uint64