3.1 NumPy多维数组数组变换*3.1.41.数组重塑对于定义好的数组,可以通过reshape方法改变其数据维度。格式:np.reshape(a,newshape, order='C')说明参数名称a需要处理的数据。新维度一整数或整数元组,newshape/例:In[15]:arrl = np.arange(8)print(arrl),arr1.reshape(4,2)print(arrl)s
3.1 NumPy多维数组 ❖3.1.4 数组变换 ◼ 1. 数组重塑 对于定义好的数组,可以通过reshape方法改变其数据维度。 格式:np.reshape(a, newshape, order='C') 参数名称 说明 a 需要处理的数据。 newshape 新维度——整数或整数元组, 例:
3.1 NumPy多维数组数组变换*3.1.41.数组重塑reshape的参数中的其中一个可以设置为-1表示数组的维度可以通过数据本身来推断In[16]:arr1 = np.arange(12)print(arrl:,arrl)arr2 = arr1.reshape(2,-1)print(arr2:,arr2)234561789 10 11]Out[16]:arrl:[012345]arr2: [ 0[6789 10 11]]
3.1 NumPy多维数组 ❖3.1.4 数组变换 ◼ 1. 数组重塑 • reshape的参数中的其中一个可以设置为-1, 表示数组的维度可以通过数据本身来推断