基本运算
import numpy as np
a = np.array([20,30,40,50])
b = np.arange(4)
c = a - b #减法
d = b**2 #平方
e = 10 *np.sin(a)
print(a<35)
A = np.array([[1,1],[0,1]])
B = np.array([[2,0],[3,4]])
C = A*B #元素相乘
E = np.dot(A,B) #矩阵相乘
print(C)
print(E)
import numpy as np
a = np.ones((2,3),dtype = int)
b = np.random.random((2,3))
print(a)
print(b)
b += a
print(b)
#a += b #error
# Cannot cast ufunc add output from dtype('float64') to dtype('int32') with casting rule 'same_kind'
print(a)
print(a.sum())
print(a.min())
print(a.max())
c = np.arange(12).reshape(3,4)
print(c)
d = c.sum(axis=0) #sum of each column
print(d)
e = c.min(axis=1) # min of each row
print(e)
f = c.cumsum(axis=1) #cumulative sum along each row
print(f)
输出