student= dtype({'names':['name', 'age', 'weight'], 'formats':['S32', 'i','f']}, align = True)
| 数据类型 | 字符编码 |
| 整数 | i |
| 无符号整数 | u |
| 单精度浮点数 | f |
| 双精度浮点数 | d |
| 布尔值 | b |
| 复数 | D |
| 字符串 | S |
| Unicode | U |
| Void | V |
a= array([(“Zhang”, 32, 65.5), (“Wang”, 24, 55.2)], dtype =student)
>>> a = arange(9).reshape(3,3) >>> a array([[0, 1, 2], [3, 4, 5], [6, 7, 8]]) >>> b = 2 * a >>> b array([[ 0, 2, 4], [ 6, 8, 10], [12, 14, 16]])
>>> hstack((a, b)) array([[ 0, 1, 2, 0, 2, 4], [ 3, 4, 5, 6, 8, 10], [ 6, 7, 8, 12, 14, 16]])
>>> concatenate((a, b), axis=1) array([[ 0, 1, 2, 0, 2, 4], [ 3, 4, 5, 6, 8, 10], [ 6, 7, 8, 12, 14, 16]])
>>> vstack((a, b)) array([[ 0, 1, 2], [ 3, 4, 5], [ 6, 7, 8], [ 0, 2, 4], [ 6, 8, 10], [12, 14, 16]])
>>> concatenate((a, b), axis=0) array([[ 0, 1, 2], [ 3, 4, 5], [ 6, 7, 8], [ 0, 2, 4], [ 6, 8, 10], [12, 14, 16]])
>>> dstack((a, b)) array([[[ 0, 0], [ 1, 2], [ 2, 4]], [[ 3, 6], [ 4, 8], [ 5, 10]], [[ 6, 12], [ 7, 14], [ 8, 16]]])
>>> one = arange(2) >>> one array([0, 1]) >>> two = one + 2 >>> two array([2, 3]) >>> row_stack((one, two)) array([[0, 1], [2, 3]])
>>> column_stack((oned, twiceoned)) array([[0, 2], [1, 3]])
>>> a = arange(9).reshape(3,3) >>> a array([[0, 1, 2], [3, 4, 5], [6, 7, 8]]) >>> hsplit(a, 3) [array([[0], [3], [6]]), array([[1], [4], [7]]), array([[2], [5], [8]])]
split(a, 3, axis=1)
>>> vsplit(a, 3) >>> [array([[0, 1, 2]]), array([[3, 4, 5]]), array([[6, 7, 8]])]
>>> split(a, 3, axis=0)
>>> c = arange(27).reshape(3, 3, 3) >>> c array([[[ 0, 1, 2], [ 3, 4, 5], [ 6, 7, 8]], [[ 9, 10, 11], [12, 13, 14], [15, 16, 17]], [[18, 19, 20], [21, 22, 23], [24, 25, 26]]]) >>> dsplit(c, 3) [array([[[ 0], [ 3], [ 6]], [[ 9], [12], [15]], [[18], [21], [24]]]), array([[[ 1], [ 4], [ 7]], [[10], [13], [16]], [[19], [22], [25]]]), array([[[ 2], [ 5], [ 8]], [[11], [14], [17]], [[20], [23], [26]]])]
>>> a = arange(12) >>> b = a #不创建新对象 >>> b is a # a和b是同一个数组对象的两个名字 True >>> b.shape = 3,4 #也改变了a的形状 >>> a.shape (3, 4) Python 传递不定对象作为参考4,所以函数调用不拷贝数组。 >>> def f(x): ... print id(x) ... >>> id(a) #id是一个对象的唯一标识 148293216 >>> f(a) 148293216
>>> c = a.view() >>> c is a False >>> c.base is a #c是a持有数据的镜像 True >>> c.flags.owndata False >>> >>> c.shape = 2,6 # a的形状没变 >>> a.shape (3, 4) >>> c[0,4] = 1234 #a的数据改变了 >>> a array([[ 0, 1, 2, 3], [1234, 5, 6, 7], [ 8, 9, 10, 11]])
>>> s = a[ : , 1:3] # 获得每一行1,2处的元素 >>> s[:] = 10 # s[:] 是s的镜像。注意区别s=10 and s[:]=10 >>> a array([[ 0, 10, 10, 3], [1234, 10, 10, 7], [ 8, 10, 10, 11]])
>>> d = a.copy() #创建了一个含有新数据的新数组对象 >>> d is a False >>> d.base is a #d和a现在没有任何关系 False >>> d[0,0] = 9999 >>> a array([[ 0, 10, 10, 3], [1234, 10, 10, 7], [ 8, 10, 10, 11]])
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有