numpy基础——ndarray.shape
2017-07-20 01:02
162 查看
numpy.ndarray.shape
ndarray.shape
Tuple of array dimensions.获得数组维度的 tuple
Notes
May be used to “reshape” the array, as long as this would not require a change in the total number of elementsExamples
>>> x = np.array([1, 2, 3, 4]) >>> x.shape (4,) >>> y = np.zeros((2, 3, 4)) >>> y.shape (2, 3, 4) >>> y.shape = (3, 8) >>> y array([[ 0., 0., 0., 0., 0., 0., 0., 0.], [ 0., 0., 0., 0., 0., 0., 0., 0.], [ 0., 0., 0., 0., 0., 0., 0., 0.]]) >>> y.shape = (3, 6) Traceback (most recent call last): File "<stdin>", line 1, in <module> ValueError: total size of new array must be unchanged
https://docs.scipy.org/doc/numpy/reference/generated/numpy.ndarray.shape.html
相关文章推荐
- NumPy基础 -- 1. ndarray (多维数组对象)
- numpy基础——ndarray对象属性
- numpy基础——关于 ndarray 的一些尝试
- 利用 Python 进行数据分析(四)NumPy 基础:ndarray 简单介绍
- 利用Python进行数据分析(4) NumPy基础: ndarray简单介绍
- numpy基础——ndarray对象方法
- NumPy基础--ndarray
- 从numpy.ndarray.shape到numpy.ndarray.transpose
- 数据基础处理-numpy
- python 中图像用SimpleITK和numpy.ndarray表示的差异
- 【Android基础】android shape详解
- numpy.ndarray.flat/flatten 与 Spark 下的 flatMap
- android之shape基础
- python:NumPy基础(1),ndarray多维数组对象
- NumPy基础入门学习
- numpy中实现ndarray数组返回符合特定条件的索引方法
- CS231n-机器学习中numpy基础.md
- numpy基础——numpy.sum
- numpy中的ndarray方法和属性
- Numpy基础