numpy之array展开

flatten()可以将二维的array展成一维的

a.flatten(order=’C’)
Return a copy of the array collapsed into one dimension.
order= 'C' means to flatten in row-major (C-style) order.
order='F' means to flatten in column-major (Fortran-style) order.

x = np.array([[1, 2], [3, 4]])
x
# array([[1, 2],
#       [3, 4]])

y1 = x.flatten()
y1
# array([1, 2, 3, 4])

y2 = x.flatten('F')
y2
# array([1, 3, 2, 4])

你可能感兴趣的:(python数据分析)