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 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
| import numpy as np
a = np.array([10,20,30,40]) b = np.array(4) print(a,b) c = a +b print(c) c = b ** 2 print(c) c = 10*np.sin(a) print(c)
print(b) print(b<3)
a = [[1,2],[3,4]] b = [[2,3],[4,5]] c = np.multiply(a,b) c_dot = np.dot(a,b) print(c) print(c_dot)
a= np.random.random((2,4)) print(a.max()) print(a.sum()) a = [[1,2],[3,4]] print(np.argmax(a)) print(np.mean(a)) print(np.median(a)) print(np.cumsum(a)) print(np.diff(a)) print(np.nonzero(a))
a = np.arange(14,2,-1) print(a.T) print(np.transpose(a))
print(np.clip(a,5,9))
a= np.arange(3,15).reshape((3,4)) print(a) print(a.flatten()) for item in a.flat: print(item)
A= np.array([1,1,1]) B = np.array([2,2,2]) C = np.vstack((A,B)) D= np.hstack((A,B)) print(C) print(D)
print(A[np.newaxis,:])
A = np.arange(12).reshape((3,4)) print(np.split(A,3)) print(np.vsplit(A,3)) print(np.hsplit(A,2))
|