无涯教程-NumPy - reshape函数
阿里云国内75折 回扣 微信号:monov8 |
阿里云国际,腾讯云国际,低至75折。AWS 93折 免费开户实名账号 代冲值 优惠多多 微信号:monov8 飞机:@monov6 |
此函数在不更改数据的情况下为数组提供了新的维度,它接受以下参数-
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]]
参考链接
阿里云国内75折 回扣 微信号:monov8 |
阿里云国际,腾讯云国际,低至75折。AWS 93折 免费开户实名账号 代冲值 优惠多多 微信号:monov8 飞机:@monov6 |