#常用的提取矩阵特定行:
>>> x
array([[6.93528128e-310, 4.68328808e-310, 1.58101007e-322],
[1.58101007e-322, 4.68328790e-310, 0.00000000e+000],
[3.16202013e-322, 1.58101007e-322, 4.68328789e-310],
[6.93528128e-310, 0.00000000e+000, 1.63041663e-322]])
>>> idx
array([ True, True, False, True])
>>> x = x[idx,:]
>>> x
array([[6.93528128e-310, 4.68328808e-310, 1.58101007e-322],
[1.58101007e-322, 4.68328790e-310, 0.00000000e+000],
[6.93528128e-310, 0.00000000e+000, 1.63041663e-322]])
>>> np.tile([0,0],(3,1))
array([[0, 0],
[0, 0],
[0, 0]])
>>> x = np.random.rand(3,1)
>>> x
array([[0.63202497],
[0.88707272],
[0.83418 ]])
>>> s = np.concatenate([x, -x],axis = 1)
>>> s
array([[ 0.63202497, -0.63202497],
[ 0.88707272, -0.88707272],
[ 0.83418 , -0.83418 ]])
>>> s = np.concatenate([x, -x],axis = 0)
>>> s
array([[ 0.63202497],
[ 0.88707272],
[ 0.83418 ],
[-0.63202497],
[-0.88707272],
[-0.83418 ]])
>>> x = np.arange(10)
>>> x
array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
>>> np.clip(x,3,7)
array([3, 3, 3, 3, 4, 5, 6, 7, 7, 7])
>>> x = np.arange(10)
>>> x
array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
>>> s = np.random.shuffle(x) # 无返回值,但是原序列变化
>>> s
>>> x
array([1, 5, 8, 0, 9, 4, 2, 7, 6, 3])
>>> y = np.arange(10)
>>> y
array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
>>> s = np.random.permutation(y) # 返回打乱后的索引,原序列没变
>>> s
array([5, 7, 2, 8, 0, 4, 9, 1, 6, 3])
>>> y
array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
# 给np.array增加维度
>>> x = np.arange(10)
>>> x
array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
>>> x.ndim
1
>>> x = x[None, :]
>>> x
array([[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]])
>>> x.ndim
2