Python-Numpy(4)常用函数

import numpy as np
B = np.arange(3)
print B
#print np.exp(B)
print np.sqrt(B)

这里写图片描述

#Return the floor of the input
a = np.floor(10*np.random.random((3,4)))
print a

#a.shape
## flatten the array
#print a.ravel()
#a.shape = (6, 2)
# print a 
print a.T
print a.resize((2,6))
print a

#If a dimension is given as -1 in a reshaping operation, the other dimensions are automatically calculated:
#a.reshape(3,-1)

这里写图片描述

a = np.floor(10*np.random.random((2,2)))
b = np.floor(10*np.random.random((2,2)))
print a
print '---'
print b
print '---'
print np.hstack((a,b))
#np.hstack((a,b))

这里写图片描述

a = np.floor(10*np.random.random((2,12)))
#print a
#print np.hsplit(a,3)
#print np.hsplit(a,(3,4))   # Split a after the third and the fourth column
a = np.floor(10*np.random.random((12,2)))
print a
np.vsplit(a,3)

这里写图片描述

#Simple assignments make no copy of array objects or of their data.
a = np.arange(12)
b = a
# a and b are two names for the same ndarray object
b is a
b.shape = 3,4
print a.shape
print id(a)
print id(b)

这里写图片描述

#The view method creates a new array object that looks at the same data.
c = a.view()
c is a
c.shape = 2,6
#print a.shape
c[0,4] = 1234
a

这里写图片描述

#The copy method makes a complete copy of the array and its data.
d = a.copy() 
d is a
d[0,0] = 9999
print d 
print a

这里写图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值