python读取矩阵的⾏和列数_Python中怎样使⽤shape计算矩
阵的⾏和列
匿名⽤户
1级
2015-05-27 回答
>>> import numpy as np
>>> a = np.arange(1,11).reshape(10,1)
>>> b = a * 1.1
>>> c = a / 1.1
>>> a
array([[ 1],
[ 2],
[ 3],
[ 4],
[ 5],
[ 6],
[ 7],
[ 8],
[ 9],
[10]])
>>> b
array([[ 1.1],
[ 2.2],
[ 3.3],
[ 4.4],
[ 5.5],
[ 6.6],
[ 7.7],
[ 8.8],
[ 9.9],
[ 11. ]])
>>> c
array([[ 0.90909091],
[ 1.81818182],
[ 2.72727273],
[ 3.63636364],
[ 4.54545455],
[ 5.45454545],
[ 6.36363636],
[ 7.27272727],
[ 8.18181818],
[ 9.09090909]])
>>> x = np.array([
... np.reshape(a, len(a)),
.
.. np.reshape(b, len(b)),
... np.reshape(c, len(c))
... ]).transpose()
>>> x
array([[ 1. , 1.1 , 0.90909091], [ 2. , 2.2 , 1.81818182],
[ 3. , 3.3 , 2.72727273],
python怎么读的[ 4. , 4.4 , 3.63636364],
[ 5. , 5.5 , 4.54545455],
[ 6. , 6.6 , 5.45454545],
[ 7. , 7.7 , 6.36363636],
[ 8. , 8.8 , 7.27272727],
[ 9. , 9.9 , 8.18181818],
[ 10. , 11. , 9.09090909]]) >>>
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论