此函数在不更改数据的情况下为数组提供了新的维度,它接受以下参数-
numpy.reshape(arr, newshape, order')
Sr.No. | 描述 |
---|---|
1 |
arr 数组 |
2 |
newshape int或int的元组,新维度应与原始维度兼容 |
3 |
order 如果数组存储在类似Fortran的连续内存中,则" C"表示C风格," F"表示Fortran风格," A"表示类似Fortran的顺序。 |
import numpy as np a = np.arange(8) print 'The original array:' print a print '\n' b = a.reshape(4,2) print 'The modified array:' print b
其输出如下-
The original array: [0 1 2 3 4 5 6 7] The modified array: [[0 1] [2 3] [4 5] [6 7]]
参考链接
https://www.learnfk.com/numpy/numpy-reshape.html
标签:维度,reshape,无涯,Fortran,numpy,print,array,NumPy From: https://blog.51cto.com/u_14033984/7882551