其他分享
首页 > 其他分享> > numpy

numpy

作者:互联网

import numpy as np

a = [1,2,3]

b = np.array(a)

b.T

(b*2).sum()

----------------

np.dtype

np.size

np.shape

np.arange(1,10,2)

np.linspace(-10,10,100)

np.zeroes(10)

np.zeroes(10,dtype='int')

np.ones(10)

np.empty()

----------------

c = np.array([ [i for i in range(10) ] , [i for i in range(10,20)] , [i for i in range(20,30)] ])

c[0]

c[0,1]

c[ [0,2] , :][:,[1,2]]

c[ (c>5) & (c%2)]   # &是位运算,优先级高

----------------

np.rint(c)   # 向0取整,等价 int

np.trunc(c) # 向0取整,等价 int

np.floor(c)  # 向下取整

np.ceil(c)  # 向上取整

np.modf(c)  # 拆分整数和小数部分

np.sqrt(c)

np.abs(c)

 

标签:----------------,10,int,range,取整,np,numpy
来源: https://www.cnblogs.com/bigcoolcool/p/16245324.html