numpy.flatten
将数组变为一维
ndarray.flatten(order='C')
Parameters: order : {‘C’, ‘F’, ‘A’, ‘K’}, optional...5
>>> x.flat = 3 # 将数组的元素均变为3
>>> x
array([[3, 3, 3],
[3, 3, 3]])
>>> x.flat[[1,4]] = 1 # 将数组重组后的一维数组小标为...1,4的元素变为1
>>> x
array([[3, 1, 3],
[3, 1, 3]])
numpy.ravel
numpy.ravel(a, order='C')
>>> x = np.array...([[1, 2, 3], [4, 5, 6]])
>>> y = np.ravel(x) # 默认order="C",按照行进行重组
>>> y
[1 2 3 4 5 6]
>>> y = np.ravel...1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11])
numpy.reshape(等价于ndarray.reshape)
numpy.reshape(a, newshape