python: numpy--函数 shape用法
2017-03-17 10:39
866 查看
shape函数是numpy.core.fromnumeric中的函数,它的功能是查看矩阵或者数组的维数。
举例说明:
建立一个3×3的单位矩阵e, e.shape为(3,3),表示3行3列,第一维的长度为3,第二维的长度也为3
建立一个4×2的矩阵c, c.shape[1] 为第一维的长度,c.shape[0] 为第二维的长度。
举例说明:
建立一个3×3的单位矩阵e, e.shape为(3,3),表示3行3列,第一维的长度为3,第二维的长度也为3
>>> e = eye(3) >>> e array([[ 1., 0., 0.], [ 0., 1., 0.], [ 0., 0., 1.]]) >>> e.shape (3, 3)建立一个一维矩阵b, b.shape 为矩阵的长度
>>> b =array([1,2,3,4]) >>> b.shape (4,) #可以简写 >>> shape([1,2,3,4]) (4,) >>>
建立一个4×2的矩阵c, c.shape[1] 为第一维的长度,c.shape[0] 为第二维的长度。
>>> c = array([[1,1],[1,2],[1,3],[1,4]]) >>> c.shape (4, 2) >>> c.shape[0] 4 >>> c.shape[1] 2一个单独的数值,返回值为空
>>> shape(3) ()
相关文章推荐
- python: numpy--函数 shape用法
- Python中Numpy的tile函数用法以及operator.itemgetter函数和sorted函数
- python: numpy-- 函数 argsort 用法
- [Python]numpy中tile函数的用法
- Python-Numpy的tile函数用法
- numpy中函数shape的用法
- Python:numpy中shape和reshape的用法
- Python-Numpy的tile函数用法
- python的numpy包中shape,tile,argsort函数与sorted函数使用方法
- Python学习——Numpy的tile函数用法
- 【Python】Numpy扩充数组函数之repeat和tile用法
- Python的numpy库中的shape用法
- 【Python】Numpy扩充数组函数之repeat和tile用法
- python: numpy --函数 tile用法
- python 的numpy库中的mean()函数用法
- 牛人总结python中string模块各属性以及函数的用法,果断转了,好东西
- Python - 函数中**参数的用法
- 详细记录python的range()函数用法
- python中List的sort方法(或者sorted内建函数)的用法
- Python print函数用法,print 格式化输出