- 版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/kun1280437633/article/details/80355988
函数
demo:
import numpy as np
b = np.arange(3)
print (b)
print (np.exp(b))
print (np.sqrt(b))
结果:
[0 1 2]
[ 1. 2.71828183 7.3890561 ]
[ 0. 1. 1.41421356]
a = np.floor(10*np.random.random((3,4))) # floor向下取整
print (a)
print (('- - - - - -'))
print (a.ravel()) # 转换成一维
print (('- - - - - -'))
a.shape = (6,2)
print (a)
print (('- - - - - -'))
print (a.T) # 转置
结果:
[[ 8. 9. 3. 6.]
[ 3. 3. 0. 5.]
[ 5. 1. 1. 5.]]
- - - - - -
[ 8. 9. 3. 6. 3. 3. 0. 5. 5. 1. 1. 5.]
- - - - - -
[[ 8. 9.]
[ 3. 6.]
[ 3. 3.]
[ 0. 5.]
[ 5. 1.]
[ 1. 5.]]
- - - - - -
[[ 8. 3. 3. 0. 5. 1.]
[ 9. 6. 3. 5. 1. 5.]]